Vaccines don't prevent infection it just helps your body to know how to fight a certain infection if/when it enter the body. A vaccine gives your body a tiny amount of a certain antigen so that the body can find the right way to fight it and keep some memory b cells to fight it if the need should arise. Say a person has been vaccinated against the flu and that strain enters their body, they still have it but there body has already seen it and can fight the infection off (hopefully) before you get sick and notice any symptoms.