Mechs are strictly worse than tanks of comparable size. There is no environment where a mecha is going to be superior to a tank.
The upright posture makes them easier to detect and target than a tank.
A smaller contact area with the ground means that they will get bogged down in soft or unstable terrain easier.
Their upright posture makes them a less stable firing platform. The higher center of gravity makes them more likely to be knocked on their side due to driver error or impact.
A tracked vehicle is more energy efficient and less mechanically complex than a mecha.
We live in a world where man portable anti tank missiles exist. If there existed an environment where a mecha could travel it would be an easy target to any well equipped infantry group.