Open the driver door of the car and kneel down inside so that you can see and reach the underside of the dash, where the pedals connect.
Remove the two or four Phillips-head screws that are behind the brake pedal and that hold the electrical cover in place. The number of screws will depend on your model and make of car. If they are not Phillips-head screws, they may be 10mm bolts, but this is not common.
Remove the cover. Inside you will see the brake light switch, which is usually held in place by two bolts. Remove these bolts with a socket wrench, and then you may remove the brake light switch and disconnect the electrical connector that supplies it with power.
Plug the electrical connector into the new brake light switch. Put the brake light switch in place, and replace the two holding bolts that were removed previously.
Replace the electrical cover and the screws that hold it in place. Turn the car on and press the pedal to test lights.