When an object (like a meteor) falls through the atmosphere towards the Earth, why does it start to heat up and glow? Is it because of the compressed air in front of it or because of drag? How do spacecrafts prevent themselves from burning as they hurtle through?
Friction and especially compression of the air in front with the air heats up the meteor, the closing speed of a meteor approaching in an opposite direction to the earth's orbital motion can be substantial, and the meteor can heat up to 10,000 degrees K. This causes ablation, a removal by heat, of the outer meteor layers.
As the fireball travels through the atmosphere, the hot vapor from ablation is compressed by collisions with atmospheric atoms and molecules. This creates an air cap or hydrodynamic cushion that protects the meteor from direct collisions, which can be seen in the figure below.
This barrier creates two macrostates in front of the meteor: One at 3500-5000K, which we will call the main spectrum, and one at 10000K, which we will call the second spectrum. [source]
Apollo 12 capsule's ablative heat shield (after use) on display at the Virginia Air and Space Center.
Image Source: Wikipedia Heat Shield Ablation
The ablated heat shield of an Apollo command module
With a space probe, normally it would be impossible to withstand this level of heat, so an ablation heat shield is used, which carries energy away from the spacecraft by, "burning" away like a meteor, but with more control over the ablation of the spacecraft surface by pitching the craft at a specified angle and by creating the ablation shield from composite materials that burn slowly.
Meteors are moving very fast when they enter the Earth's atmosphere. The frictional forces generated by the collisions with molecules of the atmosphere are responsible for the heating. Spacecraft have ceramic heat shields and insulation for protection from the high temperatures encountered during reentry.