Proteins that lose their shape
A raw egg is mostly water and protein. Each protein molecule is a long chain folded into a precise bundle, held in shape by weak attractions along its length, floating freely in the water around it — which is why raw egg white is runny and translucent. Heat shakes those weak attractions apart.
As the bundles come undone — a change called denaturing — the unfolded chains bump into each other and form new bonds, linking up into a tangled three-dimensional net. The net traps the water inside it, and the liquid egg turns solid and opaque. There is no way to refold the chains, which is why you cannot uncook an egg.
Whites first, then yolks
The parts of an egg cook on different schedules. Egg white begins to set at around 62–65 °C, while the yolk needs a few degrees more, roughly 65–70 °C. Cooks exploit the gap: a gently cooked egg can have a firm white wrapped around a yolk that is still runny.
Push the heat too far and the protein net tightens until it squeezes water out, giving rubbery whites and a chalky yolk. Leave a hard-boiled egg too long and a grey-green ring appears around the yolk — iron from the yolk meeting sulfur from the white to form iron sulfide. It looks alarming, tastes slightly of its long cooking, and is perfectly harmless.
The same trick everywhere
Denaturing is not only heat's doing. Whisking egg whites drags the proteins apart by force and traps air instead, making foam for meringues; acid does it too, which is how lemon juice 'cooks' raw fish in a ceviche and how milk curdles into cheese.
Meat in a pan is the same chemistry wearing different clothes: its proteins unravel, link, and squeeze, which is why an overcooked steak turns dry. Once you see cooking as protein management, a lot of kitchen advice — rest the meat, don't overheat the eggs, add acid at the end — suddenly makes sense.

