Sort:  

I heard that some people became infected after taking the vaccine, so both could be the reason in some cases.

You don't need to know in each individual case. This is a matter of statistical analysis.