Do you have to understand the science behind custards to enjoy them? Of course not, but if you’re curious, here’s how they work.
There are a wide variety of baked custards of largely similar composition and cooking methods that all thicken to a firm texture because of some basic kitchen science. When eggs are raw, various bonds hold the individual protein molecules in separate, tightly wound bundles. Heat breaks the bonds, causing the proteins to break out of their bundles and unwind into free-floating, flat strands, which then bump into one another and stick together. It is primarily this bonding of the egg proteins that causes custard to thicken as it is heated. Temperature is the crucial factor in this process. So long as the custard is maintained at a relatively low temperature, the egg bonds remain loose and relaxed and the custard stays smooth. But once custard approaches the boiling point, the egg proteins fuse so tightly that they harden into lumps and squeeze out all the liquid that is held between them. This situation, of course, is the sad, watery-lumpy mess that we call "curdled" custard.
Custards like crème brûlée depend on the thickening power of egg yolks. How do the yolks do it? A raw egg yolk is filled with tightly curled protein molecules, many of which contain sulfur atoms that are interspersed along their lengths. If given a chance to get together, these sulfur atoms can bond to one another, tying the protein molecules into clumps. That's what thickens a custard.
As long as the sulfur atoms are trapped within tightly wound protein molecules, however, they can't connect. When egg yolks are heated, the proteins unravel (in a process called denaturing) and the sulfur atoms are able to link up, in the process creating a tangled network of protein molecules that can hold water—in other words, a thickened custard.
But you can overdo it. If the protein molecules are heated too much, they straighten out completely, and so many sulfur atoms cross-link that the protein network tightens into tough clumps of curd, squeezing out some of the water. The result is a custard that has curdled or "weeps." That's why proper cooking creates a custard that is smooth and thick, while overcooking creates a custard that is tough and wet.