You can use a "vertical phantom" -- specifically, an invisible object that has the height and depth of the glyph "y" -- to adjust the positions of the two "x" characters in the first subformula, viz., q_x^{n_x}
.

\documentclass{article}
\newcommand{\vy}{\vphantom{y}} % vertical phantom with height and depth of "y" glyph
\begin{document}
$\displaystyle
\frac{ q_x^{n_x} q_y^{n_y} }{2}
\quad\mbox{vs.}\quad
\frac{ q_{x\vy}^{n_{x\vy}} q_y^{n_y} }{2}
$
\end{document}
Addendum: While the \vphantom
method succeeds in placing all sub- and superscripts at mutually consistent heights, one might object that the x
and y
subscripts to q
are positioned "too high". To force these subscripts to be placed a bit lower, then, one can insert \mathstrut
directives:

\documentclass{article}
\newcommand{\vy}{\vphantom{y}} % vertical phantom
\begin{document}
$\displaystyle
\frac{ q_x^{n_x} q_y^{n_y} }{2}
\quad\mbox{vs.}\quad
\frac{ q_{x\mathstrut}^{n_{x\vy}} q_{y\mathstrut}^{n_{y}} }{2}
$
\end{document}