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ā¦)
Meat and fish subjected to the same processes as UHT milk (i.e., brief explosure to ultra-high temperatures) only lasts a few days, so UHT milk lasts way longer than the comparables.