The short answer is "intuition, based on many years of experience."

The long answer is: I recognized that, for an observer moving to the left with a constant velocity c, the spatial coordinate in his frame of reference, X=x+ct (the X axis is also moving to the left with the observer) has constant density at every value of X (i.e., at each value of X, the density is not changing with time), since ##\rho=\rho(x+ct)=\rho(X)##. Basically, in the x frame of reference the density profile is traveling to the left like a wave moving at speed c, but in the X frame of reference, the density profile is stationary. This automatically led mathematically to the transformation of independent variables that we used.

Have you considered any scale like U=u/c , V=v/c, X= x/L, Y=y/L to reduce the momentum balance equation from $$ {\partial{\bf u}\over{\partial t}} + ({\bf u} \cdot \nabla) {\bf u} = - {1\over\rho} \nabla p + \gamma\nabla^2{\bf u} + {\gamma}{1\over3}\nabla (\nabla \cdot {\bf u})$$
To $$\frac{\partial P}{\partial X}=\mu \frac{\partial ^2U}{\partial Y^2}\tag{2}$$
or directly take the first term $${\partial{\bf u}\over{\partial t}}=0$$ as the flow is steady. and $$\rho{\bf u} \cdot \nabla {\bf u}={\bf u} \cdot \nabla (\rho{\bf u})=0 $$
still could not eliminate this term, $${1\over3}\nabla (\nabla \cdot {\bf u})$$
or you have considered the momentum balance equation like this $$ {\partial{\bf u}\over{\partial t}} + ({\bf u} \cdot \nabla) {\bf u} = - {1\over\rho} \nabla p + \gamma\nabla^2{\bf u} + {g_{x}} $$ as $$\rho g_{x}=0$$
Or firstly use Galilean transformation then reduce the equation.I am little confused which way to show this momentum balance equation.

I changed my mind because of your post on that other forum. So, here goes.

If we apply our coordinate transformation to the momentum equation, we obtain for the X component the following:
$$U\frac{\partial U}{\partial X}+V\frac{\partial U}{\partial Y}=-\frac{1}{\rho}\frac{\partial p}{\partial X}+\gamma\left[\frac{\partial^2U}{\partial X^2}+\frac{\partial^2U}{\partial Y^2}\right]+\frac{\gamma}{3}\left[\frac{\partial ^2U}{\partial X^2}+\frac{\partial^2V}{\partial X\partial Y}\right]$$
OK so far??