Well, the probabily of seeing the same number of heads twice is the probability that you get $0$ both times plus the probability that you get $1$ both times plus the probability that you get $2$ both times.
Now, to find the probability that you get $k$ heads if you flip a coin $n$ times, observe that the probability of seeing the specific sequence (head, tail, head) is $p_{head}(1-p_{head})p_{head}$ = $p_{head}^2(1-p_{head})^1$. In general, the probability of seeing a particular sequence with $k$ heads is $p_{head}^k(1-p_{head})^{n-k}$. To get the probabily of seeing $k$ heads, you thus have to multiply that with the number of sequences with $k$ heads. That is the same as the number of ways that you can pick $k$ elements from $n$, i.e. $\binom{n}{k}$ = $\frac{n!}{k!(n-k)!}$. You thus get that the probability of seeing $k$ heads if you flip a coin $n$ times is $ \binom{n}{k}p_{head}^k(1-p_{head})^{n-k} $
For the special case of a fair coin, i.e. $p_{head}=0.5$, you get $ \binom{n}{k}\frac{1}{2^n} $
Now, summing up the square of those probability for all possible numbers of heads gives you the probability that the same number of heads turns up twice in a row, i.e. you get $ \sum_{k=0}^{n} \left(\binom{n}{k}\frac{1}{2^n}\right)^2 = \frac{1}{2^{2n}} \sum_{k=0}^{n} \binom{n}{k}^2 $
Thus, for $n=3$ you get the probability $ \frac{1^2 + 3^2 + 3^2 + 1^2}{2^6} = \frac{20}{64} = \frac{5}{16} $ of seeing the same number of heads twice in two rows of 3 coin flips