One of the laws that makes the Universe work is that nothing changes unless a force is put on it. The forces can be pulling forces or pushing forces. In the car crash picture, we expect the drivers will have put on the brakes. That is a pulling force. It is called friction. But when the pulling force wasn't enough, the cars hit and pushed against one another.
There is a lot of energy involved here. The cars are big, heavy and moving fast. They have moving energy. All of that moving energy needs to be taken away, and that is the job of the brakes. They change moving energy to heat energy. That is why brakes get very hot. You might notice that even bike brakes get hot. Heat is another kind of energy, but it is not a moving kind of energy.
Of course, the bigger or faster something is, the more moving energy it has, and the more the brakes have to change into heat energy. So trucks and trains have far bigger brakes than bikes.
To stop the brakes burning up, they have to be made of materials that can get very hot safely. Many brake pads have a material containing powdered glass. Glass has to get very hot before it melts. They also have pieces of copper. Copper is a good conductor of heat and so will carry heat from the braking surface back to the brake support.