On the carbine, there is a rim around the bolt that will not allow the hammer to contact the firing pin unless the bolt is locked.
As to firing with the bolt unlocked, the M1 rifle is designed so that if the hammer falls before the bolt is locked, the cam on the hammer will either close the bolt or, if it can't do that, will stop the hammer before it can contact the firing pin. For some reason, this critical safety measure is almost always overlooked, while the receiver bridge cam (actually intended to retract the firing pin) is given all the credit for preventing unlocked firing.
There is some misunderstanding of slamfire vs out of battery fire. If the rifle is fired, in any way, with the bolt unlocked, there will not be a "slamfire" or a doubling, there will be almost total destruction of the rifle and probably injury to the shooter. That is why I am highly skeptical of reports of "slamfires" where the shooter says he was "startled" by the shot. Had it actually been an out of battery fire, he would have been a lot more than "startled."