I tried to solve above question using the following probability tree diagram.
Probability in each branch is = $0.5$. I double circled the satisfying toss events.
While observing the diagram I noticed that, from 2nd toss onward our required event starts showing up. Additionally,
1. in the $\text{2nd}$ toss (or the 3rd level) we have one satisfying case.
2. in the $\text{3rd}$ toss (or the 4th level) we have two satisfying case.
3. in the $\text{4th}$ toss (or the 5th level) we have three satisfying case.
4. in the $\text{5th}$ toss (or the 6th level) we have four satisfying case.
5. etc.
i.e. in the $\text{kth}$ toss we would have $(k-1)$ satisfying case.
So,
$$\begin{align*} E(x) &= \sum_{k=2}^{\infty } k.P(k)\\\ &= \sum_{k=2}^{\infty } k.\left \{ (k-1)*(0.5)^k \right \}\\ &= \sum_{k=2}^{\infty } \left \{ (k^2-k)*(0.5)^k \right \}\\ \end{align*}$$
Uisng geommetric series identity : https://en.wikipedia.org/wiki/Geometric_series#Geometric_power_series
$$\begin{align*} \sum_{k=2}^{\infty}k(k-1)x^{k-2} = \frac{2}{(1-x)^3}\ \ \text{for } |x| < 1 \\ \end{align*}$$
In our case : $x = 0.5$ So,
$$\begin{align*} E &= x^2\sum_{k=2}^{\infty}k(k-1)x^{k-2} = \frac{2x^2}{(1-x)^3} \\ \end{align*}$$
putting $x = \frac{1}{2}$ ; we get $E = 4$