Why does the gas component in a forming disc galaxy settle efficiently into a flat orbital plane?

Answer

It loses energy through friction and radiation.

The gas, being collisional, loses energy through friction and radiates that energy away as heat, allowing it to settle into the tightest possible orbital plane allowed by its rotation.

Why does the gas component in a forming disc galaxy settle efficiently into a flat orbital plane?
galaxyastronomydiskshapedisk-shaped