First no matter what, the last one happening would be Tail. P(head)=p and P(Tail)=Q
So, there are three possible events could be happen before the 2nd tail. HHTT, HTHT, THHT.
So, 3*(1-q)^2*(q^2)
Also, This an example of Negative Binomial Distribution, x=4 and n=3 p = p , and 1-p=q. by plugging these into the formula, you should get the same result. You could google the formula of Negative Binomial.