Milk curdles because its naturally occurring bacteria consumes sugar in the milk, causing it to become acidic, which creates a separation in its proteins. This is essentially the same natural process that produces cheese.
Milk contains naturally occurring bacteria that begin to feed and multiply from the moment it is cultivated. The bacteria in milk feed upon its naturally occurring sugars, also known as lactose. Once the level of lactose is depleted enough to tip the pH balance of the milk, the naturally occurring proteins in it are no longer stable enough to repel each other. Instead, they are attracted to each other and form curdles. This produces what is known as "sour milk."
This same principle is the reason why milk curdles when added to foods or beverages with a high acid content. The separated mixture is known as curds and whey, the whey being the liquid element. Contrary to popular belief, sour milk is not necessarily inedible. Ricotta cheese is milk proteins that are artificially separated from whey through the addition of lemon juice or vinegar to accelerate the souring process. It is also a little-known fact that sour milk can be safely used as a cooking ingredient.