Problem: Let $S$ be a sample space of an experiment and $S = \left\lbrace A,B,C\right\rbrace $, where $P(A)=p$, $P(B)=q$, and $P(C)=r$. The experiment is repeated infinitely, and it is assumed that the successive experiments are independent. Find the probability of the event that $A$ occurs right before $B$.
Solution (given in the book): Suppose that $A$ occurs for the first time at the $n$-th trial of the experiment. If $A$ is to have occurred before $B$, then $C$ must have occurred on the first $(n-1)$ trials. Let $D$ be the event that $A$ occurs right before $B$. Then $$D=\bigcup_{n=1}^\infty D_n$$ where $D_n$ is the event that $C$ occurs on the first $(n-1)$ trials and $A$ occurs on the $n$-th trial. Since $D_n$'s are mutually exclusive (you cannot have two different sequences as one event), we have $$ P(D)=\sum_{n=1}^{\infty}P(D_n)$$ Since the trials are independent, we have $$ P(D_n) = [P(C)]^{n-1}P(A) = r^{n-1}p$$ Thus $$ P(D) = \sum_{n=1}^{\infty} r^{n-1} p = p \sum_{k=0}^{\infty} r^k = \frac{p}{1-r} $$
Question: My way of thinking was really close to that provided in the solution. However, I do not completely understand why $P(D_n)$ does not have $P(B)$ in it? Since we are looking for all sequences where $B$ is preceded by $A$, we are looking for any sequence where we have any number of $C$ (can be even zero), then followed by $A$ and then by $B$. Therefore, an event that we are interested in, has probability: $$ P(D_n) = [P(C)]^{n-1}P(A)P(B) = r^{n-1}pq$$ where $n$ can be any natural number from $1$ to infinity, i.e. $A$ has position $n$ in the sequence and it is directly followed by $B$ at position $(n+1)$. So, in my solution the final answer is only slightly different from that from the book. We are summing over all possible infinite sequences of experiments, where $A$ can be at any position $n \in \left\lbrace 1,\dots,\infty \right\rbrace$ and is directly followed by $B$ at position $(n+1)$: $$ P(D) = \sum_{n=1}^{\infty} r^{n-1} p q = p q\sum_{k=0}^{\infty} r^k = \frac{p q}{1-r} $$
To summarize: why doesn't solution in the book have $P(B)$ component when determining $P(D_n)$?