Vaccines function by mimicking an infection, stimulating the immune system without causing illness. When a person is vaccinated, they are typically introduced to an inactivated or weakened form of a pathogen, or a piece of it (such as a protein or genetic material). The immune system recognizes these foreign components as invaders and produces an immune response. This includes the production of antibodies, which specifically target and neutralize the pathogen. The immune system also creates memory cells that "remember" how to fight the pathogen if it is encountered again in the future.
This form of "training" ensures that the body responds faster and more effectively to the pathogen upon subsequent exposures. For example, the mRNA COVID-19 vaccines work by instructing cells to produce a harmless part of the virus (spike protein), prompting the immune system to mount a defense. This preparation reduces the severity of the disease or prevents infection altogether when exposed to the actual virus.