You might be thinking of something else. UHT has a very long shelf life compared to other forms of liquid milk.

Compared to other forms forms of liquid milk indeed, but it has a rather short shelf life compared to most sterile food. (Imagine if canned meat or fish had the same shelf life than UHT milk…)