Hi,
I think you have a bad switch. To diagnose it should be straight forward, if the failure is repeatable.
You can diagnose it using a test lamp:
a) hook up the lamp with the ground clamp clipped to a known good ground.
b) test the lamp by probing the 2 wires at the brake light switch. One of the wires has constant current.
c) after determining which of the wires has current, press the brake pedal and confirm the other wire receives power. Continue to monitor the power is leaving the switch while the pedal is down.
d) If the brake lights go out, and there is is power at the wire you are monitoring, your problem is further aft.
e) If the brake lights go out and you lose power at the wire, you have a bad switch. Confirm this by rechecking the power in while you are experiencing no power out of the switch.
Hope this helps.
Rick