Let's try to expand \((x+y)^4\):
Expanding:
The first group contain 4 \(x\)'s, the second group contains 3 \(x\)'s and 1 \(y\)'s, the third group contains 2 \(x\)'s and 2 \(y\)'s, the fourth group contains 1 \(x\)'s and 3 \(y\)'s, and the fifth group contains 4 \(y\)'s. Let's look at the third group, with 2 \(x\)'s and 2 \(y\)'s.
According to this article, we know that there are \(\binom n k\) ways to arranging \(n\) items with \(k\) belonging to one group and the others belonging to another group. For the second group above, there are a total of \(\binom 4 1\) ways to arrange 4 items, with 1 belonging to one group (\(y\)), and the rest belonging to another group (\(x\)). For the third group above, there are a total of \(\binom 4 2\) ways to arrange 4 items, with 2 belonging to one group (\(y\)) and 2 belonging to the other group (\(x\)). A similar argument can be made for every other group.
We can genelarize this and say: