If you exit mech while it is powered up, you eject(and have fly high up due to ejection mechanism). Your cockpit armor is destroyed during ejection. If you exit your mech while it is powered down, you just use an exit hatch and your cockpit remains intact, thus preventing anybody but you entering it.
To steal empty enemy mech you need it's cockpit armor dropped to zero. It means that if enemy had ejected you can hop right in. Otherwise(if enemy pilot powered mech down and exited), you can use your BA weapons to destroy cockpit armor(just shoot the windshield until DH section is destroyed). After that, mech is yours to enter.
BTW, any friendly mech with it's pilot disconnected/CTDed could be entered even if it's cockpit is still intact. Keep that in mind if you see an empty friendly mech next time. Reconnected player would spawn with fresh load of cbills so he wouldn't be too upset by you taking his ride. Besides, empty mechs would despawn after some time or could just be destroyed by enemy team for free points so it's usually a good decision to take vacant friendly mech.