When a vaccine containing antigens is administered, it exposes the immune system to a harmless form of the pathogen or its components. This exposure doesn't cause the disease but rather educates the immune system to recognize and respond more effectively if it encounters the actual pathogen in the future. Immune cells called B cells produce antibodies specific to the antigens, while T cells help in identifying and destroying infected cells.