Vaccinations involve injecting small amounts of dead or inactive micro-organisms. These carry antigens, which cause your body to produce antibodies to attack them - even though the micro-organism is harmless (because it is dead or inactive). E.g. the MMR vaccine contains weakened versions of the diseases measles, mumps and rubella (German measles), all in one vaccine.
If live micro-organisms of the same type get into your body after that, then the body can rapidly mass-produce antibodies to kill the pathogen.
Booster injections are sometimes given to increase levels of antibodies again, because some vaccinations "wear off" over time.