This all depends of his "0" point is on where he is according to the world. This 0 point is right in the middle between his two feet and if that is hanging over the edge then he will fall down. If not, his foot will hang there based off his IK limits and checking to see if there's ground beneath him to set his foot on.
I'm not sure if this is 100%, but Crim could answer this better.
Kami is completely right. Now in regards to the next question if it did fall on its side it would "right itself" but you won't see mechs falling down often