The principle of immunization is based on the immune system's ability to remember.
In vaccination, the body is given a preparation of pathogen antigenic proteins or an inactivated/weakened pathogen (vaccine).
Antibodies created in the body against these antigens would neutralize the pathogenic agents during an infection.
T cells and memory B cells are also produced by the vaccines, which recognize the infection promptly upon subsequent exposure and overwhelm the invaders with massive antibody production.
In situations of snakebites, for example, the injection given to the patients contains prepared antibodies against snake venom.