Vaccines act by imitating microorganisms that cause diseases and other infectious agents such as viruses, bacteria.
Some vaccines introduce weaker viruses and help our immune system build, recognize it and fight the virus.
These "learns" the immune system to react quickly and effectively to the virus.
In addition, vaccines are used in a new way called RNA and DNA vaccines. This gives our cells a way to produce parts of the virus (not all viruses) and then equips the immune system to identify and counter the actual viruses.