As the problem only occurs after you have pressed the pedal, the fault in the circuit, a short to ground must lie after the switch.
Take out both bulbs first see if it still does it, put one back at a time, if it is still ok then look for a wire that is chaffed through or maybe even corrosion bridging the live for the brake circuit and earth somewhere between pedal and lampholder.
tabetha