The idea is that once we get a tail, the head count “resets.” Each sequence of tosses that contains five consecutive heads corresponds to one that begins with a tail, or a head and tail, or two heads and tail, or three heads and a tail, or four heads and a tail, or five heads and a tail....But if you start with five heads, well, then you're done.
More precisely, the sample space is the set $U$ of all sequences taken from $\left\{\text{head},\text{tail}\right\}$. Let $T$ be the set of all elements in $U$ that begin with a tail. Let $HT$ be the set of all elements in $U$ that begin with a head, then a tail. And so on for $HHT$, $HHHT$, and $HHHHT$. Let $HHHHH$ be the set of all sequences that begin with five heads.
These six sets partition the whole sample space. By which we mean every element is in exactly one of them. You suggest the case of two heads, one tail, one head, one tail, but any sequence beginning with those is already in $HHT$.
(We could partition the sample space by all possibilities of the first five tosses. That would result in $2^5 =32$ different sets. But this wouldn't help us with the problem of counting the number of tosses before getting the fifth head.)
From our partition of $U$ we get this equation involving the conditional expected values:
$$
E(X) = E(X\mid T)P(T) + E(X \mid HT)P(HT) + E(X\mid HHT)P(HHT) + E(X \mid HHHT) P(HHHT) + E(X \mid HHHHT) P(HHHHT) + E(X \mid HHHHH) P(HHHHH)
$$
Now $E(X \mid T) = E(X) + 1$, because if we start with a tail then we have to wait at least one more toss. To put it more precisely, $U$ and $T$ are in correspondence: for each $\omega$ in $U$, let $\omega'$ be the same sequence with a tail added to the front. Clearly $\omega' \in T$, and this is a bijection between $U$ and $T$. Since $X(\omega') = X(\omega)+1$, we have $E(X\mid T) = E(X) + 1$.
Similarly,
$$
\begin{aligned}
E(X \mid HT) &= E(X) + 2 \\
E(X \mid HHT) &= E(X) + 3 \\
E(X \mid HHHT) &= E(X) + 4 \\
E(X \mid HHHHT) &= E(X) + 5 \\
\end{aligned}
$$
But if the first five tosses are heads, we don't need any more tosses.
Therefore, $$E(X \mid HHHHH) = 5$$