A vaccine causes white blood cells to produce anitbodies. Antibodies are proteins which kill pathogens, such as viruses and bacteria. If the body is reinfected by the same pathogen as the vaccine then the white blood cells rapidly produce anitbodies in response. These anitbodies kill the pathogen.