The brake light switch on a BMW activates the brake lights when the brake pedal is pressed. The switch is located in the driver's side foot well area and is mounted to the firewall with two screws. When the brake pedal is pressed, it pushes against the switch plunger, which closes the circuit and illuminates the brake lights. When the switch fails, the brake lights will not light. Replacement brake light switches for your BMW can be purchased from most auto parts stores or directly from BMW.
Climb down into the driver's side foot well area and pull the cottar pin out from the retaining pin that connects the brake pedal to the brake booster assembly. Use a pair of pliers.
Slide the brake booster-to-brake pedal retaining pin out of the brake booster mounting bracket. This will disconnect the brake pedal from the brake booster.
Lift up on the brake pedal and unplug the electrical connector running to the brake light switch behind the brake pedal.
Unbolt the bolts holding the brake light switch to the firewall and pull the switch off the firewall.
Install the new switch. Installation is the reverse of removal. When replacing the retaining pin that connects the brake pedal to the brake booster, slide the cottar pin through the small hole in the end of the pin and bend the cottar pin back over the retaining pin. This will secure the retaining pin in place and prevent it from accidentally sliding out of the brake booster mounting bracket.
For specific information about your BMW's brake light switch, consult the particular vehicle's manual.