Applying the brake pedal causes air pressure to activate an electric switch and:

In a vehicle with air brakes, the brake lights are activated when the brake pedal is pushed and air pressure moves an electric switch. With the application of air pressure, the switch will then turn on the brake lights.
DMV Writen Test