At the same time, consumption of or damage to public goods, like the air or the water, is an externality that needs government regulation to prevent. Those things do have costs and they need to be paid by the firms using them in order to avoid market distortions. Thus, in some cases regulation can be supported on those grounds.
How the government goes about to do that, though, is tricky. It's not easy to figure out the cost of things like air pollution, or even to decide what counts as air pollution. Markets can be improved by government intervention, and this article might cite a case of one. But it's so hard to make sure that the government does more good than harm, in part due to hidden pitfalls, as your example illustrates.