There are lots of great questions and answers on this site about how and why bipedal mecha are near useless on earth, and why spiderlike mecha could perhaps have some niche uses which are unlikely to justify the costs necessary to develop them. Reasons include square cube law, movement and balance issues, repair issues, and lots of other things which basically boil down to “they are more expensive and far less useful tanks.”
But what if we take planet Earth out of the equation? I’m not necessarily talking about using handwavey “alien technology” to make mecha good, but more about how different resource availability, dominant terrain types, weather patterns, settlement types, and even factors like gravity could influence the effectiveness of mecha in contrast to modern combat vehicles and weapons.
EDIT: To clarify further, I am talking large mecha, Titanfall or Metal Gear size, ideally piloted, but not melee combat mecha with swords and things like that - more like “what changes to physical and planetary conditions would make legged armoured combat vehicles more viable than wheeled or treaded armoured combat vehicles?”