The most common cause for the shifter to stick in your 1997 Pontiac Grand Am is coffee of soda spilled in the center console. Another possibility is that there is a broken wire at the shift interlock solenoid. Removing the center console may be necessary to inspect the shifter and wiring.
There is a small rectangular plate on the passenger side of the center console next to the shifter that you can pop off and manual release it from the park position. Inside this plate there will be a flat white vertical piece with a square hole. You will need a small screwdriver or pen to insert into that square hole. While pressing on the break lift up with your screwdriver inside the hole and you should be able to change gears with your other hand. Kind of tricky, but I figured it out within a few minutes.
When this happened to me it was a fuse that blew everytime My AC would try to kick on. My AC compressor was seized up or something. I ended up disconnecting my AC, taping it with electrical tape, replacing the fuse And it put a bandaid on the problem but I still need to fix my AC compressor. Before my shifter got stuck it dropped gears like I didn't have overdrive. This happened when I was on the freeway. The AC compressor and your transmission solenoids are connected through the same fuse. Hope this gives a little peace to some.
Same problem on my '98 Grand Am. There are two different switches that get pressed by the brake pedal. The lower one operates the brake lights, and I think the cruise control. The upper one is the shift interlock. I removed this upper switch and it works fine. I have NOT been able to find a replacement yet