This explanation will look at the cases of: a) one bag contains 2 colors and the other contains and arbitrary number of colors; b) one bag contains 3 colors and the other contains arbitrary number; and c) each bag contains arbitrary numbers.
For every part below there are two bags containing n marbles. $n_{i,j}$ refers to the number of marbles of the jth color in the ith bag. $c_i$ is the number of different colors in bag i.
If anyone is willing to help confirm accuracy of this, i would be very appreciative as I've derived all of this using the referenced question as the only guide and I don't use combinatorics much.
a) As long as $c_1=2$ (as with the question's example), this problem is equivalent to just picking $n_{1,1}$ balls from the second bag.
number of combinations without repetition with limited supply
The above question helps explain how to find the number of combinations of $n_{1,1}$ marbles from bag two. Essentially you analyze the following polynomial for the coefficients:
$$P = \prod_{j=1}^{c_2}{\sum_{k=0}^{n_{2,j}}x^k}$$
For the question example:
$$P=(1+x)(1+x)(1+x+x^2+x^3) = 1+3x+4x^2+4x^3+3x^4+x^5$$
and the answer is 4 because the coefficient of $x^2$ is 4. This makes sense as the potential cases can be described as the colors paired with blue (black/black, red/black, white/black, and red/white).
b) The problem becomes more complicated when each bag contains more than 2 types of marbles. For the case of 3 colors in bag 1, the simular case requires that one consider both an x and a y. Define a polynomial:
$$F = \prod_{j=1}^{c_2}{\sum_{k=0}^{n_{2,j}}(\sum_{l=0}^{k} x^ly^{k-l})}$$
Convert it into an expanded form and note that the coefficient of $x^{n_{1,1}}y^{n_{1,2}}$ is the number of relevant combinations.
For examples, if $n=5$, $c_1=3$, $c_2=3$, $n_{2,1}=2$, $n_{2,2}=2$, $n_{2,3}=1$ then:
$$F=(1+x+y+x^2+x*y+y^2)^2*(1+x+y)$$ $$F=x^5+3 x^4 y+3 x^4+5 x^3 y^2+8 x^3 y+5 x^3+5 x^2 y^3+11 x^2 y^2+11 x^2 y+5 x^2+3 x y^4+8 x y^3+11 x y^2+8 x y+3 x+y^5+3 y^4+5 y^3+5 y^2+3 y+1
$$
If bag 2 contains 2 black, 2 red, and 1 green (for instance) there will be 11 combinations.
c) For the final case of an arbitrary number of colors in each bag, i am not sure how to write the notation. Each component in bag 1 must be assigned a letter (for instance x or y in the above examples). Define $x^ay^bz^c...$ as the state in which a are paired with color x and b are paired with color y and c are paired with color z etc. You can then define a state polynomial f such that it is the sum of all probablistic states that are possible for a particular color from bag 2 (aka f = xz+yz+zz+xy+y^2 means that the color in question can be paired with 1x and 1z, 1y and 1z, 2zs, 1x and 1y, or 2ys but 2xs are impossible. All states included in f must be mutually exclusive. Multipling all of these f state polynomials together will form an overall state polynomial F simular to those seen above. By this solution, a 1 in the f state polynomial would indicate that none of that color are chosen so would not appear in any problem where all marbles are paired up.