About 1: You get $k^n$ since for each of the $n$ elements you have $k$ choices (you choose the box), so you have $k\cdot k\cdots k$ exactly $n$ times (this is "the product principle" of combinatorics in action).
In 2 I think you're confusing the notation. The basic idea here is this: suppose you have the equation $a+b=n$ where $a,b$ can get every nonnegative integer value. One way to find the number of solutions is to compute the coefficient of $x^n$ in $(x^0+x^1+x^2+x^3+\dots)(x^0+x^1+x^2+x^3+\dots)$.
Here the first parenthesis represents the values that can $a$ can get, in the exponent of $x$; the second parenthesis represents values $b$ can get.
Now, to generalize this, all you need to do is add more parenthesis - one for each variable in the original equation - and maybe remove some elements from specific parenthesis. For example, if we have the equation $a+b+c=n$ and we demand that $a$ is odd and $b$ is even (and $c$ whatever), this is described by $(x^1+x^3+x^5+\dots)(x^0+x^2+x^4+\dots)(x^0+x^1+x^2+x^3+\dots)$
(Note the exponents).