Why does milk go off?

Milk contains bacteria. If kept cold, the bacteria grows more slowly. It feeds off of the sugar in milk, causing the consistency to thicken as more bacteria grow.