Lymphocytes are produced in response to the specific antigens on a pathogen. After the pathogen is removed some of the lymphocytes continue to remain in the immune system. These are called memory cells.
If the same pathogen enters the immune system for a second time, the response is much more rapid. This is because the existing memory cells are able to multiply rapidly, producing clones of the specific lymphocyte required to attack and destroy the pathogen before the individual exhibits symptoms.