The argument for making vaccination mandatory hinges on the fact that vaccines are not perfect–they don’t guarantee protection against the disease they are intended to inoculate against; there is a chance that someone who gets the vaccine will still get the disease.
Because if vaccines worked perfectly, then everyone could choose for themselves whether they wanted to be vaccinated, or whether they wanted to not be vaccinated and risk getting the disease. Someone else not getting vaccinated would pose no risk, in terms of transmitting the disease-causing agent, to someone who who did get vaccinated, so it would be none of their business whether other people were vaccinated.
However, vaccines are not 100% effective. There is always a chance that someone who has been vaccinated will still get the disease. The vaccine reduces the chance of infection, but not to zero. So a vaccinated person is still in a condition where more exposure to the disease-causing agent will mean a greater likelihood that they get the disease.
And there’s the justification for mandating vaccination. People who are not vaccinated are more likely to spread the disease-causing agent, so in fact by refusing the vaccine, they are selfishly putting others at risk–even those who are vaccinated. This is not acceptable, because no one has the right to make a choice that puts others at risk. It’s wrong to force other people to take on that risk.
It’s fine to make the decision for yourself to accept a risk of harm to yourself, but it’s not OK to make a decision to accept a risk of harm to other people. And that’s why we need to force other people to take a vaccine (which, like all medical interventions, in varying degrees, has a risk of harm).