Every year, the CDC's epidemiology department has to figure out which newly evolved flu strain will likely hit hardest - this is a complex analysis - but they usually concentrate on low "r-nought's" - the rate of contagion from "patient zero" as it propagates through the population. In plain terms, it means that they try to bias their results with understanding how many influenza contractions are created by one patient. This is all about virology - and you probably know that a virus is not technically alive - yet it functions by bonding to cellular membranes and injecting its own DNA strand into an uninflected host cell. By giving you a weakened or dead strand of this DNA - your immune system will start coding for that particular virus. Unfortunately, they are not mystics, they use an educated guess as to which strand of flu will wreak the most havoc and create a recommendation to the pharmaceutical houses that will develop the vaccines. That's great if you are now immune to the virus picked by the CDC - but you may be exposed to its cousin - and you get sick. There are no guarantees they will pick the right strain every year.
There are many different strains of flu. When you get a flu shot, you are getting an inoculation against the type of flu that has been determined to be the most likely to be prevalent that year. It wouldn't prevent you from getting a different type of flu.