You have a bad neutral safety switch. It will decay over time leaving you in "limp home mode" stuck in second gear. It may be worse in cold weather, or at first start up. It is a simple electro-mechanical switch that tells the car's computer and back up lights what position the gear selector is in. It is mounted under the car directly on the transmission's gear selector shaft, where heat breaks down its internal components and plastic case.
Sometimes you can get a few more months out of it by repeatedly ramming the gear shift selector back and forth through the whole lever range with the car off but the key turned to ignition unlock. This can temporarily dislodge debris from the contacts inside the switch.
I replaced mine myself, which is better if you have small hands, as space is limited. I did it without dropping any components like the exhaust or drive shaft. There is a good guide on a Volvo fan site with pictures. The switch is a hockey puck sized triangular case attached to a 3 foot cable bundle with terminal plug.