Solution 1:

It's from the sum of a (finite) geometric series. But you can derive it from first principles.

$$S_n(x) = 1 + x + x^2 + \dotsb + x^n$$

$$xS_n(x) = x + x^2 + x^3 + \dotsb + x^{n+1}$$

Subtracting the second from the first (and noting the telescoping nature, which I'm making explicit here),

$$(1-x)S_n(x) = 1 - x + x - x^2 + x^2 + \dotsb - x^n + x^n - x^{n+1} = 1- x^{n+1}.$$

Rearranging,

$$S_n(x) = \frac{1-x^{n+1}}{1-x}.$$

Solution 2:

Observe that $$ \frac{1}{x-1}(x^{k+1}-x^{k})=x^k\quad (x\neq 1) $$ whence $$ \sum_{k=0}^n x^k=\sum_{k=0}^n\frac{1}{x-1}(x^{k+1}-x^{k})=\frac{1}{x-1}(x^{n+1}-1) =\frac{1-x^{n+1}}{1-x};\quad (x\neq 1) $$ since the sum telescopes.