How many ways are there to pick 18 letters from 12 A's and 12 B's? How many ways are there to pick 12 letters from 12 A's and 12 B's?
How many ways are there to pick 18 letters from 12 A's and 12 B's?
Let's look at the generating function. We have each letter with at most $12$ elements, so we have the generating function: 
$$f(x) = (\frac{1-x^{13}}{1-x})^{2}$$ 

Your first problem can easily be solved using the stars and bars solution: $\binom{12 + 2 - 1}{12}$ is your answer. This comes from the expansion of $\frac{1}{(1-x)^{2}}$.  The expansion of $(1-x^{13})^{2} = \sum_{i=0}^{2} \binom{2}{i} (-1)^{i} x^{13i}$, so yields $1$ as the only viable term for $12$ letters. Since it is multiplied with the expansion of the denominator of the generating function, nothing changes.

With $18$ letters, we have inclusion-exclusion, which brings the expansion of $(1-x^{13})^{12}$ into play.

So we consider $(1 - 2x^{13})$ as the relevant portion of the expansion of the numerator. The $x^{26}$ term counts $26$ letter selections, which we don't care about, so we ignore it.

Now what terms in the expansion of $\frac{1}{(1-x)^{2}}$ do we multiply with terms in $(1 - 2x^{13})$ to get the count. We care about $x^{18}$ and $x^{5}$. So we have $\binom{18 + 2 - 1}{18} - 2 \binom{5 + 2 - 1}{5}$ as our answer for the number of ways to choose $18$ letters.
How many ways are there to pick 18 letters from 12 A's and 12 B's

Count the letters you are throwing away. 12 + 12 - 18 = 6 so the answer is 2 choose 6 with repetition 

${2+6-1\choose 6}$