If this was a one-off, then I'd chalk it up to a software or switch glitch. When the key is removed from the lock it let's the ECU know so the related systems can respond accordingly ie. not let you lock your key in the car. For whatever reason switch wasn't passing that information along. It could be that the particular area of the firmware related to the key was not functioning correctly. Waiting for a short period puts most of the car's systems to sleep and waking them back up is akin to a soft boot.
Or, the little microswitch in the lock could have been physically stuck open (or closed) not sure what state the switch is in when a key is inserted.
If it repeats have the dealer look at it.
Or, the little microswitch in the lock could have been physically stuck open (or closed) not sure what state the switch is in when a key is inserted.
If it repeats have the dealer look at it.