When a car hits something, it starts to decelerate (lose speed) very rapidly.
An accelerometer (electronic chip that measures acceleration or force) detects the change of speed.
If the deceleration is great enough, the accelerometer triggers the airbag circuit. Normal braking doesn’t generate enough force to do this.
The airbag circuit passes an electric current through a heating element (a bit like one of the wires in a toaster).
The heating element ignites a chemical explosive. Older airbags used sodium azide as their explosive; newer ones use different chemicals.
As the explosive burns, it generates a massive amount of harmless gas (typically either nitrogen or argon) that floods into a nylon bag packed behind the steering wheel.
As the bag expands, it blows the plastic cover off the steering wheel and inflates in front of the driver. The bag is coated with a chalky substance such as talcum powder to help it unwrap smoothly.
The driver (moving forward because of the impact) pushes against the bag. This makes the bag deflate as the gas it contains escapes through small holes around its edges. By the time the car stops, the bag should have completely deflated.