How do mining companies protect the environment?
Most mining companies protect the environment to the extent of what is spelled out in their mining permit, as issued by whatever government and country they are working in.
In most developed world countries, mining companies have to go through an extensive environmental review process, prior to getting a permit to open a mine (at least this is the case now, wasn't always so). Once a government issues a mining permit, the company must comply with whatever water, air, and land issues that have been identified in the original environmental assessment.
However, in the 1800 and 1900s, there was very little in the way of environmental laws and companies did pretty much whatever they wanted to get the minerals extracted. This has left a number of abandoned mines across North America that have never been cleaned up - so called "legacy mines".
Mining companies in many developing countries have often done a very poor job of protecting the environment. This is often because poorer countries don't often have the resources to check-up on the companies or environmental laws are either weak or non-existent.
Strangely enough, mining companies have obligations to their shareholders to NOT due more to protect the environment beyond what they are required to do by the law of the land they are in , as this adds extra costs to mining and reduces profitability.