This is an immensely complicated area of the law.
One thing that makes it complicated is that a good bit of it makes no sense to the average person. For example, why would a person buying a piece of property without knowing that a gas station once was located on the property be responsible for the “remediation” necessary to dig up the old tanks and for paying huge amounts for environmental engineers and support workers to clean up and certify that the site was safe?
So, we who participate in trying to answer questions on this site would be hard-pressed to offer much help. I would say for starters to work with a realtor to start looking at environmental specialists to see what potential liability there is. That could be lawyers specializing in this area as well as engineers who can perform some environmental testing or at least advise whether that would even be required.
But the bottom line is this: once you own the property you are responsible. You may or may not have recourse against the seller if a problem crops up -but it is much easier to address all of this prior to the purchase. On the legal side, you can also try to build in as much protection as possible in the sales contract.