The reason this can happen is that after the immune system “sees” that vaccine, it can “remember” the best way to fight the infection.
Specialized immune cells called memory T-cells know how to fight the infection. They can sit around in the body inactive for decades, but once they see the organism again, they rapidly spring into action and eliminate the infection.
So for SARS-CoV-2, the virus that causes COVID-19, there are many different types of vaccines being developed and tested. Some vaccines use parts or all of the spike protein, a protein on the surface of the virus that allows it to infect our cells. Other vaccines may actually use the entire virus, but it has been modified or deactivated so it cannot cause disease.
The immune system can likely launch a more aggressive attack against a whole virus compared to parts of it, but the bottom line is that any vaccine must produce a protective immune response.
There are over 100 SARS-CoV-2 vaccine products in development but as of the writing of this article only eight have advanced to clinical trials. Before a vaccine can be tested for effective protection, it is first tested in humans to make sure it is safe. While at this phase in development, we don’t know if the vaccine will work or not, but we may get a clue if we see study participants have an immune response to the vaccine.