vaccines contain antigens that make your body produce memory cells against a particular pathogen, without the pathogen causing disease. you can become immune without symptoms
vaccinations protect the individual vaccinated, but also others unvaccinated are less likely to catch it as fewer people have the disease overall - herd immunity
antigens may be free or attached to a dead or weakened pathogen