No vaccine prevents an infection. None. Zero. Never happens.
The best a vaccine can do is train your immune system to identify and react to the infectious agent before it gains enough of a foothold to impact you. Often, especially if you've been vaccinated with the specific strain that infected you, it can do this before you notice you've been infected. Practically giving you an immunity, but not truly, you still got infected and your immune system still fought it off.
For viruses though it's a different story. Viruses mutate, the strain you got vaccinated against may not be the one that enters your body, but the vaccine means your immune system can mount an effective response. In these cases, it significantly reduces risk of hospitalizations and death from the vaccine, but does not mean you won't have some effects from the virus.