If you're talking about the highlighted part:
For LHS, you use the binomial theorem formula, and on RHS, you expand nCk into factorial form and multiply it by 1/n^k. The reason why it ends at (n-k+1) is because the remaining terms cancel out with (n-k)! in the denominator