A car’s handbrake is the lever to a completely mechanical braking system, which will bypass the primary hydraulic system if it fails. When the handbrake is applied, the brake cable passes through an intermediate lever, to increase the force of your pull; this force is then split evenly between your brakes by an equaliser.
Typically, a mechanical lever is added to the existing disc or drum brakes on the car. In drum brakes, the handbrake cable runs directly to a lever on the brake shoes. In disc brakes an additional lever and corkscrew is added to the existing calliper piston. When the handbrake is pulled, the lever forces the corkscrew against the piston, which would normally be activated by the hydraulic foot pedal system.
Although it is reassuring to have a secondary braking system for emergencies, the primary use of the handbrake tends to be when parking as they remain engaged until a release button is pressed; stopping your car potentially rolling away. This is good practise, as it keeps your brake cable from seizing up, ready for when you really need it. In fact, using your handbrake to stop a moving car can actually damage the brake system, so it is best to save this for real emergencies!