When your immune system encounters a new pathogen for the first time, it takes some time for it to develop the new antibodies.
If the same type of pathogen enters the body again, your immune system recognizes it and the lymphocytes immediately start producing lots of the correct antibody/antitoxin.
The person is now immune to that disease.