The same protein denaturing that keeps cookies fluffy happens when you cook an egg.
The white of an egg is a transparent gel before cooking. The proteins are dissolved in water, but they have electrical charges on their surfaces that make them repel one another. This gives the liquid its gel form, and keeps much of the egg white in a high puddle around the egg yolk.
There are several different proteins in the egg white. Some are more gelled than others. If you crack an egg, you will see a runny, almost watery protein solution on the outside, and a firmer gel of egg white towards the center.
As we heat the egg white, some of the proteins denature sooner than others (at a lower temperature). As the proteins unfold, the electrical charges that were on the inside are available to form bonds on the outside. The proteins take up more space as they get bigger and start to bond with one another.
These larger proteins scatter light more effectively than they did when all the molecules were smaller than a wavelength of visible light. Instead of a transparent gel, the egg proteins become as white as clouds, which scatter light in the same way.
As the temperature rises, more of the proteins denature and bond together. The proteins in the yolk are the last to solidify, at the highest temperatures.