Operation varies by mfg. 1911 types often use a locking mainspring housing that blocks the hammer spring from being moved down by the strut. S&w block hammer rearward travel. Both operate by a key.
I think the real answer is internal locks work to add several completely un-neccesary pieces to a gun all of which may or will break when you can least afford it or be mysteriously locked. Further, they just build a false sense of security.
"Don't worry, it's not loaded"......Booom!
"Don't worry, the safety is on".....Boooom!
"Don't worry, the internal lock is on".....Booom!
"Don't worry, it's unloaded, the safety is on, and the internal lock is engaged"......Booooom!
Insert bleeding and profuse apologies to dying friend/family member here.
All guns are always loaded. Carry them or put them in a safe.
As far as safeties, external locks, internal locks, smart guns, etc. It is a gun, it is not safe.