Vaccination prevents illness in an individual by training the person's immune system to respond and protect them from getting a particular infection. It fights off the germ and remembers it so it can attack in case that specific germ comes back again in the immune system.
By immunizing a large proportion of the population to prevent the spread of disease, the people are resistant to the disease by a vaccine. It also means that fewer people will be infected and the disease spreading has a lower chance of infecting so many people.
I hope this helps answer your question! Have a nice day! :D