After you follow the advice above, if you find the switch is bad:

Those brake light switches seem to be quite reliable but they can get dirty, rusty, and tight. Does the lever move freely when you depress the pedal?

I have "saved" several tight stoplamp switches/levers by liberal use of penetrating oil and movement of the lever until it moved freely. If the switch is no good, it is easy to replace and it is not very expensive.