The flu virus can be a direct cause of viral pneumonia. The CDC says that everyone 6 months or older should get the seasonal flu vaccine. The only exceptions are people who have had allergic reactions to flu vaccines or eggs and people who have had Guillain-Barre syndrome.
If you’re sick at the time you’re supposed to get a flu shot, you should wait until you’re feeling better to get it.