Difference between geometric distribution and negative binomial distribution

How do I differentiate between a problem of geometric distribution and that of Negative Binomial Distribution? Both include something around first success or failure. I'm confused.

Negative binomial is a distribution of a number of successes $$k$$ before observing $$r$$ failures when observing independent Bernoulli trials with the probability of success $$p$$. It has probability mass function

$$f(k)= \binom{r+k-1}{k} p^k(1-p)^r$$

With geometric distribution, you stop your experiment after observing first failure, i.e. it is negative binomial $$r=1$$,

$$f(k) = p^k (1-p)$$

Notice that usual naming convention with geometric distribution is that it is about observeing failures $$r$$ until first success, where the probability of success is $$q=1-p$$, so the probability mass function is written as

$$f(r) = (1-q)^r q$$

The only difference between both formulations is what you consider as a "success" and what as a "failure" (e.g. if you count heads or tails in series of coin tosses). With this formulation, $$\mathcal{G}(q) = \mathcal{NB}(1, 1-q)$$.

Check also the When to use Poisson vs. geometric vs. negative binomial GLMs for count data? thread, that discusses their usage in generalized linear models.

In geometric distribution, you try until first success and leave. So, you must consecutively fail all the time until the end. In negative binomial distribution, definitions slightly change, but I find it easier to adopt the following: you try until your k-th success. So, the remaining $$k-1$$ success can occur anywhere in between your $$k$$-th success and your start, which requires a combination calculation. For $$k=1$$ of NBD, the two distributions are equivalent. Sometimes the fail and success definitions may change depending on the source, some focus on fails etc. however the key difference is in NBD we might encounter with more than one success.

The wiki page for NBD uses the definition number of successes until a specified number of fails occur. This can be converted to number of fails until a specified number of successes occur, which is closer to us. We were counting the number of trials, which is $$f$$, number of fails, larger than this definition.

A source using the exactly sam definition with ours is here.