The reason we have extended lifelines on milk and other fresh products is due to enhanced sterilisation, quality and and hygiene standards within the food industry.
So for example, UHT (long-life) is the ultimate as it goes through super heat sterilisation and is packaged within same environment.
Our fresh milk is homogenised and pasteurised, whiuch is a form of sterilisation. It goes off proportionally to the remaining bacteria left within it's packaging environment, coupled with the higher temperatures and light levels that these bacteria multiply at.
It can be quite common for the manufacturing/processing plant to be suffering from an "infection" (pasteuriser leak letting in air) which can culminate in long periods of milk going off before due date.