Any given vaccine can fail to produce immunity in an individual, and some vaccines, like the influenza vaccine, are less effective than others. But when enough people are vaccinated with even a relatively ineffective vaccine, viruses have trouble moving from host to host and cease to spread, sparing both the unvaccinated and those in whom vaccination has not produced immunity.

