I'm assuming that it is similar to the trap in your sink. Except because hydrogen is the lightest element, it has to be upside down. Confident that this is for preventing backflow when the valve is closed and the pipe is opened for maintenance.
Edit: I appear to be incorrect and it has to do with handling the expansion and contraction of the pipe.