Here is how partial fraction decomposition works. First, take a fraction like $\frac{1}{n(n+1)}$. You can express this fraction as the sum $\frac{A}n + \frac{B}{n+1}$ for some constants $A$ and $B$. Thus, you have the equation $\frac{1}{n(n+1)} = \frac{A}n + \frac{B}{n+1}$. Now, multiply both sides by $n(n+1)$ to get $1=A(n+1)+B(n)$. However, note that the expression $\frac{x}{x} = 1$ ONLY when $x \ne 0$ because division by $0$ is forbidden. Thus, $1=A(n+1)+B(n)$ only if $n \ne 0,-1$ because these are the values that cause division by $0$. However, many people plug in $n=0,-1$ to solve for $A,B$ even though that is an illegal move, and it works.
Plugging in $n=0$, we get $1=A$. Plugging in $n=-1$, we get $1 =-B$, thus $B=-1$. So, we have $\frac{1}{n(n+1)} = \frac{A}n + \frac{B}{n+1} = \frac{1}n - \frac{1}{n+1}$. This is true.
However, I don't understand why it works, even though you used an illegal move?
This is a good question, and it's quite subtle and almost no one mentions it; the reason is continuity. Let $P:\Bbb{R}\to\Bbb{R}$ be a polynomial function, $\{a_1,\dots, a_k\}$ all of its roots, and let $f:\Bbb{R}\to\Bbb{R}$ be a continuous function. Suppose you know that for all $x\in\Bbb{R}\setminus\{a_1,\dots, a_k\}$ \begin{align} \frac{1}{P(x)}&=\frac{f(x)}{P(x)} \end{align} Then, for these values of $x$, it follows that $1=f(x)$. Now since $f$ is a continuous function, the same equality holds even if $x\in\{a_1,\dots, a_k\}$. Therefore, for every $x\in\Bbb{R}$ without exception, we have the equality $1=f(x)$.
In your case, we're applying this reasoning to $P(n)= n(n+1)$ and $f(n)=A(n+1)+Bn$.
More generally, we can make the following observation: