Vaccination protects a person from a disease before they ever catch it. A vaccine contains small quantities of dead or inactive forms of a pathogen. These cannot cause the disease, but they carry antigens that the white blood cells recognise as foreign.
The white blood cells respond to the vaccine by producing antibodies. If the same pathogen later enters the body, the white blood cells respond quickly and make the correct antibodies in large numbers, so the pathogen is destroyed before it can make the person ill. The person is now protected against that disease.
Vaccination also protects a whole population. If a large proportion of people are immunised, the pathogen finds it hard to pass from person to person, so the spread of the disease is reduced. This helps even people who have not been vaccinated, because they are less likely to meet an infected person. Vaccination has been used worldwide to prevent disease, and some diseases have become rare as a result.