Why does the consistency of an egg change from liquid to more or less solid as it cooks? The important change is in the arrangement of the protein molecules.
A protein molecule is a long chain of smaller molecules, the amino acids. The amino acids are linked by strong bonds between atoms. Those chains are not likely to break while you're cooking an egg.
A Compact Ball
But another change does happen when you turn on the heat under a raw egg. In a raw egg each protein molecule is folded up into a compact ball. There are weak bonds between atoms that hold the protein molecule in its folded-up position.
When you heat the egg you increase the tiny random jiggling motion of the molecules. In any material warmer than absolute zero, the atoms and molecules move around at random. Higher temperature means faster random motion.
Fast Random Motions
As the egg heats, the random motion gets fast enough to break the bonds that keep the proteins folded up. So the protein molecules unfold.
The kind of weak bonding that once held the protein molecules in a folded position now works in another way. Here and there, a loose end of one protein molecule comes alongside a loose end of another.
The loose ends overlap and bond side-to-side. As the egg gets hotter, the spliced proteins form a mesh with water filing in the spaces within the mesh. As more protein molecules unfold and connect to each other, the mesh gets stronger and the egg becomes more solid. When the mesh is strong enough for your taste, you take the egg off the heat.
So, when you cook an egg, the important change is in the arrangement of the protein molecules. They unfold, connect to each other, and form a mesh that gives the egg its new, solid, cooked consistency.
Want to know more about eggs? If you've ever wondered about whether or not eating the eggs you buy from the grocery store is equivalent to eating a baby chick, we've got a past episode for you to read.
Harold McGee, On Food and Cooking: The Science and Lore of the Kitchen (1985).