Well first, the law's of thermodynamics have to do with conservation of energy, transfer of energy to do work, and usable energy lost as heat. You're thinking about Newtons laws of motion, namely the second law (for every reaction there is an equal and opposite reaction.)
Anyways, yes latching onto an asteroid would be an unstable firing platform because it would be moving, but so would the mech if it's just out their floating in space. By attaching to the asteroid the mech effectively increases it's total mass, and therefor it's resting momentum. so when the gun fires, the recoil force has has more momentum to overcome before it causes a change in movement to the mech+asteroid combo. in space any force will cause an object to start moving because of the lack of friction, but a relatively small force will make the object move much slower.
As for blocking his filed of view, maybe. But the big 'ol asteroid, is going to to make a fairly effective shield for from fire on that side and provides a moderate amount of camouflage that would be lacking if the mech was simply floating in space.
Ideally, you'd want your sniper mech to be anchored to the deck of the carrier it deploys from with a Bigger gun to allow it to hit targets from the considerable range the carrier would be from the actual fighting. the poo would be a much more stable platform to fire from, being both orders of magnitude more massive and therefor more resistant to recoil forces than the asteroid, and being equipped with it's own engines and maneuvering thrusters allowing it to compensate for the recoil forces exerted on it. The problem with this though is that the mech pilot is mow far removed from the action of the battle. This would be fine in real life but in the context of a show it removes the pilot from the drama and tension of the fight. it's good tactics but not good storytelling or film making.