Consider a matrix $P$ and $D$,
$ P =\begin{bmatrix} 8 & 7 \\ 2 & 4 \\\end{bmatrix} $ and $ D =\begin{bmatrix} 6 & 0 \\ 0 & 1 \\\end{bmatrix} $
which are defined as, $ A = PDP^{-1}$.
To find $ A^{50} $, the equation $ A^{n} = PD^{n}P^{-1} $ is used.
But since, $ PP^{-1} = I $, shouldn't the equation for finding the $n^{th}$ power of a matrix be simply, $ A^{n} = ID^{n}?$
Generally, for matrices, $AB\neq BA$, except in certain very specific circumstances. Hence, if we know that $A^n=PD^nP^{-1}$, we cannot conclude that $PDP^{-1}=PP^{-1}D$.
Before I talk about why this is true, it should be clear why you cannot make such a rearrangement. You already said you know that $A=PDP^{-1}$. If you could rearrange the order of the terms here, or "commute" them, then $A=PP^{-1}D=ID=D$. Then you could say that every diagonalizable matrix $A$ is equal to its diagonal matrix $D$, which is obviously not true.
More generally, matrices represent linear transformations, and matrix multiplication is equivalent to the composition of these transformations. Remember that the composition of any functions will not in general be commutative, and this can of course be extended to the case of linear transformations.
Instead, for your specific question, we must observe first (as you did), that $A^n=PD^nP^{-1}$. Then we must note that for any diagonal matrix $D=\begin{bmatrix} a & 0\\ 0 & b \end{bmatrix}$, raising to a power $n$ yields $$D^{n}=\begin{bmatrix} a^n & 0\\ 0 & b^n \end{bmatrix}$$.
To see why this is true intuitively, try doing the first few multiplications out by hand. To prove the more general statement, it is easiest to proceed by induction on $n$.