why isn't it an electronic lock that prevents operation of the machine if it's not locked?
Because that would throw the liability on the facility when the system inevitably failed, or was bypassed because the $1000 lock mechanism was preventing the $10m MRI from working.
Much easier to slap up a couple of warning signs and tell people not to be dumb.