How is UHT milk heated to a high temperature for only 1–2 seconds?
According to this product page from Machine Point:


  MachinePoint Food Technologies manufactures injection direct heating
  systems where high pressure steam is injected into pre-heated liquid
  by a steam injector leading to a rapid rise in temperature between 80
  and 145 ºC for 0,5 seconds. Following the product is flash-cooled in a
  vacuum to remove water equivalent to amount of condensed steam used,
  until we reach the 80ºC. Then temperature keep been reduced by a heat
  exchanger.


Physics is fun.

I suspect the various methods are proprietary, depending on what is being pasteurized, but for economy of scale, they are all going to involve a continuous process similar to the one described, where the product enters a heating phase, then very quickly moves into a cooling phase in the machine.

In these continuous types of processes, of course the product will move continuously through all temperatures, but it will do so very quickly.