The immune response is how your body recognizes and defends itself against antigens. Antigens are bacteria, viruses, or any other foreign substance that has entered the body.
You are referring to primary and secondary immune responses to antigens. The primary immune response occurs when your body encounters an antigen for the first time. During this first time, the body must recognize antigen and then decide how to fight it with antibodies. During this process, the body produces memory lymphocytes.
When the body encounters an antigen for the second time (or anytime thereafter), it already has memory on how to fight it. This means the body can go to work producing antibodies immediately, meaning it can be fought off faster than being exposed the first time. This typically means the body can fight and heal from the antigen in a shorter time frame, making it less harmful to the body overall.