Having a properly functioning immune system helps you to weather infections, but it cannot prevent you from getting sick from a pathogen if you do not have pre-existing immunity against that specific pathogen.
The flu virus recognizes and binds to specific cell surface receptors in your respiratory system. Those receptors carry the virus inside the cell, where it takes over and forces that cell to produce new viruses. The only way your body can prevent this process is by having circulating antibodies that recognize and attach to that virus, which physically prevents the virus from attaching to the cell receptors. Once the antibodies attach to the virus, they signal other components of the immune system to destroy the virus.
No amount of vitamin D or "immune system enhancement" can substitute for the presence of specific antibodies that recognize and neutralize specific viruses.