I have the following solution:
Let $$Y_j = \begin{cases} 1, & \text{if $j$th toss is a head} \\ 0, & \text{if $j$th toss is a tail} \end{cases}$$
Let $X$ denote the waiting time to $HH$. First, we note that, if any toss is a tail, then the experiment regenerates. In particular, if $Y_1 = 0$, then the experiment regenerates. Therefore, we have that
$$E[X \vert Y_1 = 0] = E[X] + 1.$$
On the other hand, for the case where the first toss is a head, the law of total expectation -- with extra conditioning on $Y_1 = 1$ -- gives us that
$$\begin{align} E[X \vert Y_1 = 1] &= \sum_{y = 0}^1 E[X \vert Y_2 = y, Y_1 = 1] P(Y_2 = y \vert Y_1 = 1) \\ &= E[X \vert Y_2 = 0, Y_1 = 1] P(Y_2 = 0) + E[X \vert Y_2 = 1, Y_1 = 1] P(Y_2 = 1) \end{align}$$
Wikipedia gives the law of total expectation as follows:
If ${\displaystyle {\left\{A_{i}\right\}}_{i}}$ is a finite or countable partition of the sample space, then
$${\displaystyle \operatorname {E} (X)=\sum _{i}{\operatorname {E} (X\mid A_{i})\operatorname {P} (A_{i})}.}$$
How is the author's application of the law of total expectation consistent with the definition?
I would greatly appreciate it if people would please take the time to explain this.
To answer "How is the author's application of the law of total expectation consistent with the definition?"
I think the Tower Property can explain it better. Tower property: For sub-σ-algebras $\mathcal H_1\subset \mathcal H_2\subset \mathcal F$ we have $$ E(E(X\mid \mathcal H_2) \mid \mathcal H_1)= E(E(X\mid \mathcal H_1)\mid \mathcal H_2)=E(X\mid \mathcal H_1)$$
Define $\mathcal H_1=\sigma(Y_1)$ and $\mathcal H_2=\sigma(Y_1,Y_2)$ so $\mathcal H_1 \subset \mathcal H_2\subset \mathcal F$ $$\begin{align} \mathbb E[X \vert Y_1 ] &\overset{\text{Tower property}}{=} \mathbb E\left( \mathbb E[X \vert Y_1 ] \mid Y_1,Y_2\right) \\ &\overset{\text{Tower property}}{=} \mathbb E\left( E[X \vert Y_1 ,Y_2 ] \mid Y_1\right) \\ &= \mathbb E\left( g(Y_1 ,Y_2 ) \mid Y_1\right) \\ &= \sum_{y} g(Y_1 ,Y_2=y )\mathbb P(Y_2 = y \vert Y_1 ) \\ &= \sum_{y } \mathbb E[X \vert Y_2 = y, Y_1] \mathbb P(Y_2 = y \vert Y_1 )= \cdots \end{align}$$