This post consists of two parts: a long introduction, and a short solution.
The problem is not optimally worded. We make an interpretation, partly based on the answer provided.
Each family keeps breeding until it has achieved its goal of $2$ girls and then stops, whether or not the other families have managed to meet their quota. And we are invited to assume that the probability that a birth results in a girl is $\dfrac{1}{2}$, and to make the usual assumption of independence.
Introduction: There are a couple of unfortunately different descriptions of the negative binomial distribution. We either count the total number of trials until the $r$-th time that a certain event, often called a "success," occurs. Or else we count the number of what are usually called "successes" until the $r$-th failure. Note that the notion of success and failure are reversed, and even after we do the reversal, the answers differ.
We use the second interpretation of "negative binomial." I checked, this is the interpretation described in Wikipedia. The probability of success is often called $p$. In our case, we end up calling the birth of a girl a failure. Sorry about that!
Let $X_1,X_2,\dots,X_m$ be independent negative binomials, where $X_i$ measures the number of successes until the $r_i$-th failure. Suppose that for each of these $X_i$, the probability of success is $p$. Let $Y=X_1+X_2+\cdots +X_m$. Then $Y$ has negative binomial distribution, with the same "$p$," and $r=r_1+r_2+\cdots+r_n$.
One can prove this by a calculation (the case $m=2$ is enough). But it is also intuitively clear. Because it is important to think the right way about these things, we give a brief explanation.
Take a general negative binomial $W$, the number of successes until the $r$-th failure. Then $W$ is a sum $H_1+H_2+\cdots +H_r$ of $r$ independent random variables, where $H_j$ is the number of successes until the first failure.
Thus $X_1+X_2+\cdots+X_m$ is a sum of $r_1+r_2+\cdots+r_m$ independent random variables of type "$H$," and is therefore negative binomial.
Solution of the problems: So the total number of successes is the number of boys until the $6$-th girl. All of the analysis in the introduction was probably not necessary. The situation is the same as if a single family kept breeding until it had $6$ girls. But the problem is a good excuse for discussing the general situation.
The probability that the total number of boys is $k$ is
$$\binom{k+5}{k}p^k(1-p)^6,$$
where $p$ is the probability of a boy, in this case $\dfrac{1}{2}$.
The mean total number of boys is $\dfrac{6p}{1-p}$, in this case $6$.
To derive the mgf of the negative binomial distribution we are going to use the following identity:
$$\binom{-r}{y}=\left( -1 \right)^y \binom{r+y-1}{y} $$
We can prove that in the following way:
$$\begin{align}
\binom{-r}{y} & = \frac{ \left( -r \right) \left(-r-1 \right) \ldots \left(-r-y+1 \right)}{y!}\\
& = \left(-1 \right)^y \frac{ \left(r+y-1 \right) \ldots \left( r+1 \right)r}{y!} \\
& = \left(-1 \right)^y \binom{r+y-1}{y}
\end{align}$$
Now
$$M \left( t \right)=\sum_{y=0}^{\infty} e^{ty} \binom{y+r-1}{r-1} \left( 1-p \right)^y \times p^r $$
Grouping terms and using the above idenity we get:
$$\begin{align} M \left( t \right)& =p^r \sum_{y=0}^{\infty} \binom{y+r-1}{r-1} \left[ e^t \left( 1-p \right) \right]^y \\&=p^r\sum_{y=0}^{\infty} \binom{-r}{y}\left( -1 \right)^y\left[ e^t \left( 1-p \right) \right]^y \\& =p^r\sum_{y=0}^{\infty} \binom{-r}{y}\left[ -e^t \left( 1-p \right) \right]^y \end{align} $$
Then using Newton's Binomial Theorem: $\left( x+1 \right)^r= \sum_{i=0}^\infty {r\choose i}x^i$ provided that $|x|<1$, the last term becomes:
$$M \left(t \right)= \frac{p^r}{\left[ 1- \left(1-p \right)e^t \right]^r}$$
provided that $t<-\log(1-p)$
Note that the negative binomial distribution can come with a slightly different parameterization as well, as it has been pointed out in the comments. I leave it to you to derive the mgf for the other case.
Hope this helps.
Best Answer
The first reply will give you the correct answer, but if you need to use the negative binomial function to generate the pmf...
The equation for the negative binomial is: $$nb(x;r,p)= {x+r-1\choose r-1} p^r (1-p)^x$$ where r = number of successes, p = P(S), and x = the number of failures prior to the rth success. That last part is important to understand in order to solve the rest of the problem. For this problem, p = .5, and r = 3 as the 3rd child of the same gender is where the parents will stop. This gives us: $$nb(x;3,\frac{1}{2})= {x+2\choose 2} \frac{1}{8} (\frac{1}{2})^x$$ (Trust me, using fractions will make this easier to calculate by hand.) If unfamiliar, the large parenthetical indicates a combination process and should be read as "$x+r-1$ choose $r-1$" or in plain English, "out of $x+r-1$ items, how many ways can I select $r-1$ items." You would calculate it for this problem, using this equation: $$\frac{(x+2)!}{2!((x+2)-2)!}$$
First thing to note is that you can achieve success by having either 3 girls or 3 boys. "Either" and "or" indicates a union of two sets, which would also mean the addition of probabilities. Since P(G) = P(B), then whatever probabilities you get for a given x value, you can simply double it in order to show the probability for both cases, 3 boys/3 girls, as the negative binomial equation will not change.
Second thing to note is that $0 \le X < 3$ because there are only two options. 3 failures before the 3rd success then implies that 3 children of the opposite gender were born. Since this would mean success, it is logically impossible for them to have 3 failures before the 3rd success. Thus, X can't be equal to or greater than 3.
From here, it's quite easy. Use the possible x values in X's domain and double your result to get the correct p(x) needed to create a pmf.
I know this seems like overkill, but given how the question was asked, this would be the way to solve it while using the negative binomial.