I had this issue with my 2016 Impreza. After pulling apart the center console, I figured out what was causing my issue.
To move the shift knob the driver needs to squeeze in the button on the front (blue circle in the picture). This lifts up a rod through the knob (red line in picture) . with the rod up the shift knob can be moved into gear. The rod also presses a button when in park, releasing the key. My issues was the rod was not dropping all the way down and activating the switch. I pulled the rod out and put some light grease on it, hasn’t been a problem since. It was not to much work to get the rod out but I don’t remember exactly how.
Sorry its so late, maybe this will help someone else