It’s not entirely clear why the length of acquired protection varies with different vaccines. A single dose of some vaccines provides lifelong immunity, while others require an additional dose (boosters) in order to maintain immunity. Boosters can be described as a ‘reminder’ to your immune system.
Read: If vaccines confer long-term protection, why do they have to be repeated?