How are these three things equal?
You have, for each compound, $\mu_i = \mu^\circ_i + RT\ln(P_i/P^\circ)$.
So, replacing each potential in $\Delta G$ by its expression, assuming $P^\circ = 1$ bar, we get :
$$\Delta G = c(\mu^\circ_C + RT\ln(P_C)) + d(\mu^\circ_D + RT\ln(P_D)) - a((\mu^\circ_A + RT\ln(P_A)) - b(\mu^\circ_B + RT\ln(P_B))$$
Then we develop and group standard potentials and logs:
$$\Delta G = (c\mu^\circ_C + d\mu^\circ_D - a\mu^\circ_A - b\mu^\circ_B) + RT(c\ln(P_C) + d\ln(P_D) - a\ln(P_A)-b\ln(P_B))$$
Then, using calculation rules on logarithms:
$$\Delta G = (c\mu^\circ_C + d\mu^\circ_D - a\mu^\circ_A - b\mu^\circ_B) + RT\left(\ln({P_C}^c)+\ln({P_D}^d)-\ln({P_A}^a)-\ln({P_B}^b)\right)$$
And finally, since $-\ln(x) = \ln(1/x)$ and $\ln(x)+\ln(y)=\ln(xy)$,
$$\boxed{\Delta G = (c\mu^\circ_C + d\mu^\circ_D - a\mu^\circ_A - b\mu^\circ_B) + RT\ln\left(\frac{{P_C}^c{P_D}^d}{{P_A}^a{P_B}^b}\right)}$$
Then, try expressing the quotient of the reaction in terms of partial pressures, assuming standard pressure is 1 bar and you'll find out it gives the inside of the log!