It is very important to educate yourself on vaccinations and whether or not they are appropriate for you.
Flu vaccines help develop immunity to the flu by imitating an infection. This infection does not cause illness, but causes the immune system to produce antibodies. Once this "infection" goes away, the body "remembers" how to fight that infection in the future. However, it can take a few weeks for the body to produce these antibodies after vaccination. Therefore, it is possible to get the flu if you are exposed to the virus just before or just after you get vaccinated because your body has not had enough time to build up protection.
As with all medications/vaccinations, check with your doctor or pharmacist to see if the flu shot is appropriate for you.