First of all, for clarity, I will use the following variables: $r$ for the number of red balls, $y$ for yellow, $g$ for green, and $b$ for blue. I will denote the total number of balls by $n$.
Out of the total number of permutations of 9 balls selected from the $n$ total, we only want to consider certain permutations. We want at least one of the first seven selections to be yellow, one of the remaining seven selections (one is taken by the yellow ball) to be green, three of the remaining seven selections to be red, and one of the 4 still remaining selections to be blue. The remaining four unspecified selections could be anything.
There are ${{y}\choose{1}}\cdot{{7}\choose{1}}$ ways of a yellow ball taking one of the first seven positions.
There are ${{g}\choose{1}}\cdot{{7}\choose{1}}$ ways of a green ball taking one of the first eight positions, after one has already been specified as yellow.
EDIT: There are ${{r}\choose{3}}\cdot{{b}\choose{1}}\cdot{{7}\choose{4}}\cdot{{4}\choose{1}}$ ways of three red balls and one blue taking four of the remaining seven positions. (And we choose one of the four positions to be taken by the blue ball.)
There are still three positions left, and we have already placed six balls, leaving us ${_{n-6}}P_3$ possible ways to fill the remaining positions.
Thus the total number of possible permutations that satisfy the requirements is ${{y}\choose{1}}\cdot{{7}\choose{1}}\cdot{{g}\choose{1}}\cdot{{7}\choose{1}}\cdot{{r}\choose{3}}\cdot{{b}\choose{1}}\cdot{{7}\choose{4}}\cdot{{4}\choose{1}}\cdot{_{n-6}}P_3$
out of a total of ${_n}P_9$ permutations.
$1.$ With replacement: There are three ways this can happen, red, red, red; blue, blue, blue; and green, green, green.
The probability of red, red, red is $\left(\dfrac{5}{19}\right)^3$. Find similar expressions for the other two colurs, and add up.
$2.$ Without Replacement: The probability of red, red, red is $\left(\dfrac{5}{19}\right)\left(\dfrac{4}{18}\right)\left(\dfrac{3}{17}\right)$. Find similar expressions for the other two colours, and add up.
Remark: We could also do the problem by a counting argument. Let's look at the first problem. Put labels on the balls to make them distinct. Then for with replacement, there are $19^3$ strings of length $3$ of our objects. (The three objects in the string are not necessarily distinct.) All of these $19^3$ strings are equally likely.
There are $5^3$ all red strings, $11^3$ all blue, and $8^3$ all green. This gives probability $\dfrac{5^3+6^3+8^3}{19^3}$.
One can do a similar calculation for the without replacement case.
For without replacement, there is a third approach. We can choose $3$ objects from $19$ in $\dbinom{19}{3}$ ways. And we can choose $3$ of the same colour in $\dbinom{5}{3}+\dbinom{6}{3}+\dbinom{8}{3}$ ways.
Best Answer
For this post, I will use $n\frac{r}{~}$ to denote the falling factorial: $$n\cdot(n-1)\cdot(n-2)\cdots(n-r+1)=\frac{n!}{(n-r)!}$$
I will make a few changes to notation. It should be clear why I did so in a moment. Let us instead talk about the total number of red balls as $I$ and the total number of blue balls as $J$. Further, let us talk about the total number of balls as $I+J = N$. We will then be wanting to draw $n$ balls total, and let $i$ instead represent the total number of red balls that happened to have been drawn (rather than the total number available) and similarly $j$ be the number of blue balls that were drawn.
Imagine that the balls are all uniquely labeled. Recognize then that each of the $N\frac{n}{~}$ ways of selecting $n$ balls in sequence from the $N$ available balls are equally likely to have occurred.
Let us consider a specific sequence of colors of balls that contains $i$ red balls and $j$ blue balls. Let us count how many ordered sequences of labeled balls result in this sequence of colors.
From left to right, decide which specific red ball occupies a space intended for a red ball to go. The first time there will be $I$ options for the specific red ball, then $I-1$ for the next, and so on... resulting in $I\frac{i}{~}$ ways in which we may select which red ball happened to go in which spot.
Similarly, from left to right, decide which specific blue ball occupied a space intended for a blue ball to go. As before, this will result in $J\frac{j}{~}$ ways in which this can be done.
We get then a probability of:
$$\dfrac{I\frac{i}{~}\cdot J\frac{j}{~}}{N\frac{n}{~}}$$
Notice, this does not change based on the order in which the colors of the balls occurred. It is exactly as probable to have gotten a sequence
RBBBBB
as it is to have gotten a sequenceBBBBBR
. While yes the probability that the first ball is red is less than the probability that the $n$'th ball is red given that the first n-1 balls were blue, that is irrelevant and what we should have been asking is what the probability is that the first ball was red compared to the probability the $n$'th ball was red where this second probability is not conditioned on anything. This is similar to how it is equally likely to have drawn a queen on the first draw of a deck as it is to have drawn a queen on the second draw from a deck or indeed the $n$'th draw from a deck for any $n$.From the above observations and derived formula, we can then further derive the formula for the hypergeometric distribution by accounting for all of the $\binom{n}{i}$ orders in which we could have seen red vs blue balls.