"The needs of the many outweigh the needs of the few (or the one)." - Surak
"The needs of the one outweigh the needs of the many." - Kirk
Case A. An individual releases toxic substances into the unowned environmental commons where it is breathed in by many members of the community for the individual's benefit and to some community-members' cost. This is pollution.
Case B. The community releases toxic substances into an individual where it is ingested by the individual for the community's benefit and to some individuals' cost. This is immunization.
Is A bad and B good?
A produces in economic terms a "negative externality", an unwanted side-effect on third-parties. (Strictly speaking, pollution may also produce positive externalities, e.g. some agriculture may benefit from a change in the chemical composition of the air, or change in temperature, etc., these are often thought to be relatively small compared to the downsides)
B produces a "positive externality" (a good side-effect on third parties) [e.g. Herd immunity is whereby the immunity of a significant portion of the population protects others from disease, as it limits the ability of viruses to spread.]
So long as most individuals benefit from immunization, people seem to let it slide. But there have been a number of immunization attempts that were not generally successful, where the downsides may have outweighed the upside, the 1976 Swine Flu immunization is an example, where the flu killed 1 person, and the immunization killed 25 (of course, the story is quite complicated, and those who were immunized in 1976 were less likely to get ill in the 2009 outbreak, so it may have been net positive in the long run).
Pollution exists and is known to cause harm. Most people think all else equal, pollution is bad for society. There is debate on how much to regulate or price pollution, as well as the magnitude of the harm caused from individual pollutants. In the US, air pollution in general is down, though decreasing some pollutants may increase other pollutants (e.g. processes that reduce the size of pollutants may reduce the amount of large particulates but increase the number of small, less easily measured, particulates).
It is known that vaccines have side effects, it is not known in advance which unlucky individual will be the recipient of those side effects.
If you are a communitarian, A is unacceptable, B is acceptable. If you are an individualist, A is acceptable and B should be voluntary.
An individualist may willingly submit to immunization, but only if their personal benefit outweighs their personal cost, not strictly for herd immunity of for the benefit of others (unless those are things that they get salutary benefits from, either from a feeling of moral righteousness or from rising in status do to the perceptions of others). They believe society does not have the right to forcibly vaccinate individuals, or coerce individuals into vaccination in exchange for mandatory services (e.g. public education).