Trace of the mutiplication of many identical matrices

I found the following derivation in my textbook confusing:

For a $2\times2$ matrix $V=\left[ {\begin{array}{cc} a & b \\ c & d \\ \end{array} } \right]$, we know its eigenvalues "$\lambda_1$" and "$\lambda_2$".

Let $P$ be the 2-by-2 matrix with column eigenvectors, i.e.$P=(x_1, x_2)$, we have: $V=P\left( {\begin{array}{cc} \lambda_1 & 0 \\ 0 & \lambda_2 \\ \end{array} } \right)P^{-1}$ --------(1)

The trace of $V^N$:

$Trace (V^N)=\lambda_1^N+\lambda_2^N$. --------(2)

I understand that by substituting (1) into (2), we can cancel $P$ and $P^{-1}$ out. But what about the first $P$ and the last $P^{-1}$? How are they canceled out?

They aren't. But$$V^N=P\begin{pmatrix}{\lambda_1}^N&0\\0&{\lambda_2}^N\end{pmatrix}P^{-1}.$$Therefore, $V^N$ and $\left(\begin{smallmatrix}{\lambda_1}^N&0\\0&{\lambda_2}^N\end{smallmatrix}\right)$ are similar and so they have the same traces.

$$V=P\begin{bmatrix} \lambda_1 & 0 \\ 0 & \lambda_2\end{bmatrix}P^{-1}$$

$$V^N=P\begin{bmatrix} \lambda_1^N & 0 \\ 0 & \lambda_2^N\end{bmatrix}P^{-1}$$

$$\operatorname{trace}(V^N)=\operatorname{trace}\left(P\begin{bmatrix} \lambda_1^N & 0 \\ 0 & \lambda_2^N\end{bmatrix}P^{-1}\right)=\operatorname{trace}\left(\begin{bmatrix} \lambda_1^N & 0 \\ 0 & \lambda_2^N\end{bmatrix}P^{-1}P\right)=\operatorname{trace}\left(\begin{bmatrix} \lambda_1^N & 0 \\ 0 & \lambda_2^N\end{bmatrix}\right)$$

Recall that $\operatorname{trace}(AB)=\operatorname{trace}(BA)$.

$V^N=(P\left( {\begin{array}{cc} \lambda_1 & 0 \\ 0 & \lambda_2 \\ \end{array} } \right)P^{-1}).(P\left( {\begin{array}{cc} \lambda_1 & 0 \\ 0 & \lambda_2 \\ \end{array} } \right)P^{-1})...(P\left( {\begin{array}{cc} \lambda_1 & 0 \\ 0 & \lambda_2 \\ \end{array} } \right)P^{-1})$ (n times)

Observe that internal multiplication of $P$ and $P^{-1}$ leads to the Identity matrix $I$ and so we are left with $P$ on the extreme left and another $P^{-1}$ on the extreme right(which you see do not cancel out)and there is a $n$ times multiplication of the diagonal matrix, which has $\lambda_{1}$ and $\lambda_{2}$ on the main diagonal and hence when multiplied the terms on the main diagonal are $\lambda_{1}^n$ and $\lambda_{2}^n$ and the is a diagonal matrix too and the trace we thus obtain is $\lambda_{1}^n+\lambda_{2}^n$ due to $Tr(AB) = Tr(BA)$ as per Siong Thye Goh's answer!