Milk if not put in the refrigerator or not added with any preservative gets sour after some time because of a bacteria lactobacillus.
Milk contains harmless bacteria called lactobacillus, which uses lactose (milk sugar) for energy and creates lactic acid as a by-product. It is the lactic acid which makes milk taste sour.