I am trying to write 2 to the power of 2 to the power of k, and $2^2^k$ instead gives 2 to the power of 2k.
$2^{2^k}$
${2^2}^k$
$({2^2})^k$
Just use the curly braces, grouping the exponents:
$m_{n_k}$
or even
$m_{n^2}$
A pair of curly braces creates a group - it means that TeX in many cases treats grouped part of the formula as one single object.
$2^{2^k}$or${2^2}^k$or maybe even$({2^2})^k$, depending on your context. – Steven B. Segletes Jul 07 '20 at 18:29