How is pollution a market failure?
There are certain factors of production (and their corresponding profit in blue)
Let's, for example, say I am going to produce some life-saving chemical that I have just discovered. I need a place to produce it, therefore I pay to hire a place.
Next up I want some machine to produce lots of it and I buy some machines where I have to pay for them.
I cannot do everything on my own and I will pay workers do help me out.
Now I earn money with the chemical and I, sort of, pay myself for the company that I just set up.
What I do not have to pay for, is the pollution in this process, since the air is not for sale. I am not going to pay people in surrounding for the negative side effect that my company has because I do not know how much I should pay them. What is air worth?
This very oversimplified situation shows that we consider polluting doesn't costs money. Not only is this by making some chemical, but this can also happen in you use some natural resources (trees, rocks, oil).
In this example, I do not think far ahead of what this pollution could do to nature since the effects are hard to determine. Maybe when producing like this will result in a problem in 50 years.
How to counter these pollution problems?
Now the government comes into place. Since it is a collective problem the government will make up laws to stop this market flaw. This can, for example, be done by only allowing factories to have a certain amount of pollution per year or other restrictions.
I just want to note that I am not a specialist on this subject and that this answer is most probably not complete and or contains some mistakes, but it can give you some information about your question.