After an infection has been defeated, some B cells remain in the blood as memory cells, along with any leftover antibodies. Together, these form your immune system's memory of the pathogen, so if you're infected by the same pathogen again, the third line of defense will respond faster and stronger than it did the first time. It works so fast you don't even get sick. This is what it means when you become immune to the disease.