The ignition on my 2017 Subaru legacy interminenly locks when put in park. Starting the engine and putting it in gear and then in park sometimes releases the key when it is turn to the off position. Other times requires the additional step on stepping on the brake. This problem is becoming more frequent. I took it to Subaru and they sprayed some graphite in the lgnition assy. and said to call if it continued to happen.
It sounds like your “shift interlock” mechanism is failing and should be replaced under warranty
Agree with @old_mopar_guy but will add that putting graphite in an ignition lock is not a real good idea. Graphite is conductive and could cause a short circuit in the electrical part. I know that the lock and tumbler assembly and the ignition switch itself are two different parts, but they are back to back and there isn’t much of a seal between them.
The service dept. at the dealership are the ones that sprayed in the graphite. If a problem arises from that then it is on them.
The car is out of warranty with 108,000 miles on it. It is getting time to trade it in.
In 3 years? Wow, you drive a lot.