The general formula for calculating the state state vector is of a Markov Chain with two states $\mathbb{X}=\{A,B\}$ (A,B are the states, not to be confused with $a,b$ the probability values in your transition matrix):
$$\begin{equation}(\pi_{n}(A),\pi_{n}(B))=(\pi_{n}(A),\pi_{n}(B))P^{n}
\end{equation}$$
In order to calculate $P^{n}$ for any value of $n$ we can diagonalise matrix $P$.The characteristic equation $|\lambda I-P|=0$ of $P$ has eigenvalues $\lambda_{1}=1$ and $\lambda_{2} = 1-(b+a)$ (a,b) from your matrix.
The according eigenvectors are : $$u_{1}= \begin{pmatrix}
1 \\
1
\end{pmatrix}$$ and $$u_{2}= \begin{pmatrix}
-b \\
a
\end{pmatrix}.$$ Therefore $$P = \begin{pmatrix}
1 &-b\\
1 &a
\end{pmatrix}\begin{pmatrix}
1 &0\\
0 &\lambda_{2}
\end{pmatrix}\begin{pmatrix}
1 &-b\\
1 &a
\end{pmatrix}^{-1}.$$
So we have $$P^{n} = \begin{pmatrix}
1 &-b\\
1 &a
\end{pmatrix}\begin{pmatrix}
1^n &0\\
0 &\lambda_{2}^n
\end{pmatrix}\begin{pmatrix}
1 &-b\\
1 &a
\end{pmatrix}^{-1} = \frac{1}{b+a}\begin{pmatrix}
a+b \lambda_{2}^n & b- \lambda_{2}^n \\
a-a \lambda_{2}^n & b+ \lambda_{2}^n
\end{pmatrix}$$
Substituting in the first equation we take : $$(\pi_{n}(A),\pi_{n}(B))=\left( \frac{a}{b+a},\frac{b}{b+a} \right) + \lambda_{2}^n \frac{b \pi_{0}(A) - a \pi_{0}(B)}{b+a}(1,-1)$$