I have an inconsistent problem. Sometimes I can’t shift out of park. The last time I got it serviced the mechanic oiled the pin and it was better for a while but now it has started to lock up again.
Maybe it just needs to be lubed again. Another possibility is the brake interlock gadgets are failing. Those are there as a safety device to force you to press on the brake pedal before you can shift out of P. But if the safety gadgets fail it can prevent you from shifting out of P. Sometimes there’s another way to shift out of P in an emergency provided by the manufacturer for this exact situation. Refer to your owner’s manual.
I had someone have me look at their Ford Van with that same problem. I picked it up on my way home. It was dark. I noticed the brake lights only worked occasionally when I braked. Replaced brake switch and all is well.