The environment might require it
It has been suggested that the lack of line of sight in an urban environment, especially coupled with dense fighting where ammunition might be limited could advantage a fast, repeatable weapons system. This also seems to allow things like laser cannons. These sorts of atmospheres would also help explain the odd absence of air superiority already mentioned.
Dense atmosphere
But what if the 'air' of the world the fight was taking place on was especially opaque? A near equivalent on earth would be fighting in a very strong sandstorm, or underwater. This sort of environment could plausibly prevent optical weapons and small arms fire from functioning, and an urban or choppy terrain would prevent/discourage rocket based weaponry.
Reactive atmosphere
A highly flammable or chemically reactive atmosphere, perhaps one very high in gaseous hydrogen and oxygen, would cause large fires/explosions when a rocket or laser was fired. The mechs could well be shielded or armored sufficiently to prevent machine gun fire from being strong enough to damage them meaningfully for the weight it imposes on the holder.
There might not be room on a mech to defend against everything
It's not hard for me to imagine that the shielding/defense/armor strategies that defend against lasers/swords/rockets might all be different. If there wasn't a unified technology to defend against the varied attacks you would have to make speed/size and energy tradeoffs in defending a mech. These things are going to be awfully heavy, and on the sort of rough terrain already described as preventing tanks, maybe you just can't have all the different technologies on the mech and still have it able to transverse the terrain. 898
It could also provide to much of a power or resource drain on either the mech or the society building them. This sort of scenario is, to some extent, why we don't only use tanks as it is. There are just places you can't go if you weigh 100 or 200 tons.
Those weapons don't exist
As in some of <PERSON> books, you might imagine a world where the technology for lasers/rockets either can't or doesn't exist. If gunpowder and rocket fuel were much more complicated to invent, it doesn't necessarily preclude the invention of computers, robotics and nuclear power. So you could have this sort of weaponry evolve from a society that never develops any sort of firearm. A similar scenario could be accomplished by envisioning the development by an alien species with very limited sight. They might never develop firearms because they can't use them, but they are able to develop mechs that interface well with their other senses, and are armed as the society has always been, with swords and the like. 477