Expected number of flips needed that at least two heads and one tail have been flipped
Let $q=1-p$, $P=1/p$, and $Q=1/q$ for convenience. Some brief scratch paper work will verify that $pP=qQ=1$, $pQ=Q-1$, and $qP=P-1$.
Let's solve part (a) first, since it will be useful. Your first flip is either heads or tails. If it is heads, then we expect it will take $Q$ flips for the first tails to come up. If it is tails, then we expect it will take $P$ flips for the first heads to come up. Therefore, if $A$ is the expected number of flips before we see both heads and tails, then $$E[A]=p(1+Q)+q(1+P)\\=p+pQ+q+qP\\=1+(Q-1)+(P-1)=P+Q-1\\=(P-p)+(Q-q)$$
The same effort applies to the second part. Your first flip is either heads or tails. If it is heads, then we expect it will take $A$ flips to get another head and a tail. If it is tails, then we expect it will take $2P$ flips for two heads to come up. Therefore, $$E[B]=p(1+E[A])+q(1+2P)\\=p(P+Q)+q(1+2P)\\=pP+pQ+q+2qP \\=1+(Q-1)+q+2(P-1)\\=Q+q+2P-2\\=Q+q+2P-(2p+2q)\\=2P-2p+Q-q=2(P-p)+(Q-q)$$
Thanks to bof for recognizing that this collapses into an elegant form.