What exactly happens in the algebraic steps here? $$ \frac{n(n+1)}{2} + (n+1) = (n+1)(\frac{n}{2} + 1) = \frac{(n+1)(n+2)}{2} $$
I don't understand what happens from the first to the second and from the second to the third one.

For the first equality, $n+1$ is factored out. But it is easier if read from right to left:
$$
(n+1)\bigg(\frac{n}{2}+1\bigg) =  (n+1) \cdot \frac{n}{2}+ (n+1) \cdot 1 = \frac{n(n+1)}{2}+(n+1)
$$
For the second equality, the sum $\frac{n}{2}+1$ is evaluated:
$$
(n+1)\bigg(\frac{n}{2}+1\bigg) = (n+1)\bigg(\frac{n}{2}+\frac{2}{2}\bigg) = \frac{(n+1)(n+2)}{2}
$$
