when you are infected by a pathogen, it takes your white blood cells a few days to learn how to deal with it
vaccinations involve injecting small amounts of dead/inactive pathogens. These carry antigens. For example MMR vaccine carry weakened versions of the virus measles, mumps and rubella
if live pathogens of the same type appear after that, the white blood cells can rapidly reproduce to kill pathogens
Pros of vaccination
helped to control lots of communicable diseases that were once common in the UK
Big outbreaks of disease (epidemics) can be prevented if a large percentage of the population is vaccinated