When the body is exposed to an antigen, either through infection or vaccination, the immune system responds by producing specific antibodies. These antibodies recognize and neutralize the pathogen, preventing it from causing illness. Additionally, the immune system retains a memory of the antigen, allowing for a faster and more effective response if the pathogen is encountered again in the future.