The next state depends only on the current one; a row of probabilities times the transition matrix P steps forward, so after n steps the distribution is π₀Pⁿ.
Weather that tends to persist, a customer switching brands, a board-game token: in each, the next state is random, but its chances depend on the current state. A Markov chain models this. Its one-step behavior is a table of conditional probabilities, and many steps are computed by matrix multiplication.
🔑 Key idea
A Markov chain has the property that, given the present state, the past does not matter: $$P(X_{n + 1} = j \mid X_n = i, \text{earlier states}) = P_{ij}$$ The transition matrix $P$ has row $i$ listing the chances of moving from state $i$, so every row adds to 1. A distribution is a row vector $\pi_n$, and $$\pi_{n + 1} = \pi_n P, \qquad \pi_n = \pi_0 P^{n};$$ entry $(i, j)$ of $P^{n}$ is the chance of going from $i$ to $j$ in $n$ steps.
💡 Why it works
Condition on where the chain is now, using the law of total probability: $$P(X_{n + 1} = j) = \sum_i P(X_n = i)\,P_{ij}.$$ The right side is the row vector $\pi_n$ times column $j$ of $P$, so $\pi_{n + 1} = \pi_n P$. Repeating, $\pi_n = \pi_0 P^{n}$. Starting surely in state $i$ makes $\pi_0$ a row of zeros with a single 1, and then $\pi_0 P^{n}$ is row $i$ of $P^{n}$.
Mind the convention. Here, as in most probability books, rows of $P$ add to 1 and the distribution is a row vector multiplied on the left. The Linear Algebra lesson on Markov chains uses the transpose: columns add to 1 and $\mathbf{x}_{k + 1} = P\mathbf{x}_k$ with column vectors. The two describe the same chain.
A two-state weather chain. Each step multiplies the row of probabilities by the matrix, and one entry of the product is written out as a row times a column.
Worked examples
✏️ Worked example: Two steps ahead
Weather: from Sunny, tomorrow is Sunny or Rainy with probability $\frac{1}{2}$ each; from Rainy, Sunny with $\frac{1}{4}$ and Rainy with $\frac{3}{4}$. Today is Sunny. Find the chance the day after tomorrow is Rainy.
Write S for Sunny and R for Rainy, and condition on tomorrow: $P(X_2 = R) = P_{SS}P_{SR} + P_{SR}P_{RR}$.
Multiplying on the wrong side, $P\pi_0$, with a matrix whose rows add to 1; that mixes the wrong entries and need not even give a distribution. Another slip is writing rows that do not add to 1, for example by listing the chances of arriving in a state along a row. Check: every row of $P$, and every $\pi_n$, adds to 1.
Practice
Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.
Grinstead and Snell, Introduction to Probability (2nd revised edition, American Mathematical Society; free from Dartmouth College), chapter 11 (Markov Chains), section 11.1
MIT OpenCourseWare 18.440, Probability and Random Variables (Spring 2014), lecture notes on Markov chains