How do vaccines prevent disease?

Building immunity. By injecting material that is identical to the stuff that makes up the shell a germ lives in, you can trigger the immune system to make an anti-body that will attack anything that tries to invade the body dressed in that shell. This can be made new in a lab or just by killing the germ & using the left over shell.
Immune response. Its more complicated than 400 words can say, but vaccines contain the same antigens or parts of antigens that cause diseases. When they are injected into fatty tissue or muscle, vaccine antigens are not strong enough to produce the symptoms and signs of the disease but are strong enough for the immune system to produce a response. See ttp://www.Cdc.Gov/vaccines/vac-gen/howvpd.Htm.