A litle bit scary, hey! My v40 2001 did the same thing. While at a red light with engine warmed up, keep an eye on the dial of the engine temperature, if you see it jumping up and down suddenly to red, the engine will jump from 600 to at least 2000 rpm even with fully brake applied. A false positive case is trying to lower engine temperature by having the engine cooling fluid to circulate more rapidly.
With an automatic transmission and your foot naturally applying enough power on brake to stand still, your car try to jump over the red light.
Watch the engine temp gauge again if jumping up and down when these situations happened.
For me,the engine temperature sensor on the engine was the culprit. Easy to change.
Fixed my problem.
At that time, I was surprised that a Volvo car with an automatic transmission and a simple faulty heat sensor was overriding my driving and responsibility in a sensible situation where you could have pedestrians in front of your car..