This problem is related to the negative binomial distribution, which has several versions (see the link under 'alternative formulations'). You should compare the various formulations with your text to avoid confusion. For this Answer I use a formulation used in many elementary texts.
In a sequence of independent Bernoulli trials with Success probability $p,$ let $X$ count the the number of trials $x = r, r+1, \dots$ until $r$ Successes have been observed.
Before the last trial (a Success), there must have been $x-1$ trials with $r - 1$ Successes. There are ${x-1 \choose r-1}$ possible arrangements of Successes and Failures each with probability $p^{r-1}(1-p)^{x-r}.$ The final trial must be a Success with probability $p$. Thus $$P(X = x) = {x-1 \choose r-1}p^r(1-p)^{x-r}, $$ for $x = r, r+1, \dots .$
In your problem, $r = 2, p = \frac 12,$ so that $$P(X = x) = (x-1)\left(\frac 12\right)^2\left(\frac 12\right)^{x-2} = (x-1)\left(\frac 12\right)^x. $$
According to this formulation of a negative binomial random variable $X,$ we have $E(X) = \frac rp = \frac {2}{1/2} = 4$ and $Var(X) = \frac{r(1-p)}{p^2}= 4,$ which can be found using moment generating functions (or some other argument using differentiation).
For your problem, we can use R to sum the first 100 terms of (three) infinite series to get good approximations:
x = 2:102; pdf = (x-1)*(.5)^x
sum(pdf)
[1] 1 # 100 terms include almost probability 1
mu = sum(x*pdf); mu
[1] 4 # for E(X), aprx with 100 terms very close
sum(x^2*pdf) - mu^2
[1] 4 # also for Var(X)
Note: The formulation of the negative binomial in R with functions dnbinom, and so on (not used above), counts the number of Failures before the $r$th Success. Examples:
mean(rnbinom(10^6, 2, .5) + 2) # mean of sample of size 1 million
[1] 4.001245
x = 2:12; pdf = (x-1)*(.5)^x; pdf
[1] 0.250000000 0.250000000 0.187500000 0.125000000 0.078125000 0.046875000
[7] 0.027343750 0.015625000 0.008789062 0.004882812 0.002685547
dnbinom(0:10, 2, .5)
[1] 0.250000000 0.250000000 0.187500000 0.125000000 0.078125000 0.046875000
[7] 0.027343750 0.015625000 0.008789062 0.004882813 0.002685547