The adaptive immune system has a remarkable capacity to learn. Once exposed to a given antigen – such as a protein from an influenza virus strain – certain immune system cells called memory B cells "remember" that antigen for the rest of the individual's life. But influenza mutates so rapidly that it can become unrecognizable to B cells that remember a previous version of the virus.
In fact, just like other vaccinations, the influenza shot confers long-term immunity. The repeated vaccinations are needed because there is not just one virus that causes influenza, but many. Influenza is a rapidly changing virus, and there are countless strains, only a few of which are dominant at any given time. Both Influenza A and Influenza B, the two most serious species of flu virus, mutate at a steady clip through a process called antigenic drift. Antigenic drift refers to changes in the surface proteins of the virus particle that affect how the immune system recognizes the virus.