More than likely you are losing vacuum due to a leaking power brake booster. When the brake pedal is depressed vacuum is probably bypassing the internal seal and causing a drop in vacuum that the engine requires for operation. I needed to replace one recently in the price range of $50.00-60.00 for the brake booster plus labor unless you are an experienced mechanic.
What could be the problem when a 2002 Volvo won't stay stared
my brake light stay on but emergency brake is unhooked
vacuum hose
Probably a brake light switch.
Adjust the brake switch which is above the brake pedal.
somebody put a single filiment bulb in a dual receptacle socket or visa versa chech rear bulbs first
You could be low on brake fluid.
check the brake light switch
The brake relay switch is bad.
Bad brake switch
Have you checked your brake fluid?
I would check the brake regulator switch, located under the dash near the top of the brake pedal. Its a silver piece that has a button like switch that activates every time you press on the brake pedal causing the light to turn on. It could be stuck in, causing the brake light to stay on.