Vaccines function by mimicking the presence of a toxin without causing disease. They contain inactivated or attenuated forms of the toxin or a small but harmless part of the toxin, such as a protein. When administered, these vaccine components trigger an immune response, leading to the production of specific antibodies and memory cells. Upon subsequent exposure to the actual toxin, the immune system can respond swiftly and effectively, neutralizing the threat.