Would need to know more about the circumstances under which it happens, and also some idea of the vehicle, so as to determine if you have ABS, ATC/SATC, disc or drum brakes, etc. This requires much more knowledge of the vehicle and diagnosis than what the information in your question accounts for.
If the ABS and brake light are coming on while driving, this is an indicator that it is time to get your brakes checked and replaced. If not, the brakes will wear out causing you to not be able to stop.
Your brake calipers have pistons that can after years of driving and not properly flushing the brake system become frozen. You may also want to replace the brake hoses at the same time as they can sometimes produce locked brakes as well.
In an emergency stop, yes you slam on the brakes and hold the pedal to the floor while at the same time steering around the obstacle if possible.
no i do it all the time with cars whithout brakes. try it ill make this crazy loud sound
Most of the time it is caused by the disk (rotor) being warped for previous "locking up" the brakes. If you've ever slammed on the brakes that could be the reason why. Basically it's a rotor problem most of the time.
hypothisies
hypothisies
Daughters' 97 acted like it was on glare ice..she was on summer time pavement. Making the clicking noise with no brakes. Fuse was under hood on drivers side by front of car. Pulled it and brakes are fine. Anti lock doesn't work...ABS light is on...but brakes work fine and she can lock 'em up if she needs to. Told her how to "pump" brakes in icy conditions. Insurance companies HATE anti lock brakes.
Yes it would help to know what you are driving. But in General this is a feature the the Manufacturers have put in to help in the prevention of Car Jacking. It was also started a while back to keep children from opening the car door while it is moving. As to why it does not lock all the time you put it in gear that is where it would help to know what make and model you are driving.
theory
Bad logic
Stomp your brakes and keep strong pressure on them while at the same time steering around the obstruction if possible. You will hear lots of noise and feel vibration in the brake pedal. All of this is normal so do not release the brake pedal.