Vaccines can last your entire lifetime, but their effectiveness decays over time it largely depends on the disease and your risk of infection. Booster shots for various vaccines have been common for example, it’s recommended people take a Tdap booster every 10 years, Tetanus every 4-6 etc.
The flu vaccine is a special case as it’s changed every year.
In the original use of the vaccina virus against variola (smallpox) infection, symptomatic smallpox could present after vaccina exposoure of at least five years past.
"Smallpox vaccination provides a high level of immunity for three to five years and decreasing immunity thereafter. If a person is vaccinated again later, the immunity lasts even longer. Studies of smallpox cases in Europe in the 1950s and 1960s demonstrated that the fatality rate among persons vaccinated less than 10 years before exposure was 1.3 percent; it was 7 percent among those vaccinated 11 to 20 years prior, and 11 percent among those vaccinated 20 or more years before infection. By contrast, 52 percent of unvaccinated persons died."
The flu vaccine is a special case as it’s changed every year.