The technique you are looking for is polynomial division.
We attack the highest degree term first because we want to reduce to a simpler problem.
Here we want to divide $n^2+1$ by $n+1$. Looking at the highest term we see we wasn't to eliminate the $n^2$ term, so we need to multiply $n+1$ by something that gives us an $n^2$ term. The obvious candidate is $n$, because $n(n+1)=n^2+n = n^2+1+n-1$ so that $$n^2+1=n(n+1)-n+1$$
The remainder here is $-n+1$ which has the same degree as $n+1$, so we can reduce further. To get a $-n$ term we need to multiply $n+1$ by $-1$ so that $(-1)\cdot(n+1)=-n-1=-n+1-2$ and $$-n+1=(-1)\cdot (n+1)+2$$ whence $$n^2+1=n(n+1)-n+1=n(n+1)+(-1)(n+1)+2=(n-1)(n+1)+2$$
Note that, provided the coefficients of the polynomial are not limited (so if rational numbers are allowed), we can divide a polynomial $f(x)$ by $p(x)$ to give $$f(x)=p(x)q(x)+r(x)$$ where $r(x)$ has a lower degree than $p(x)$
The comment about the limitation on coefficients is illustrated by the fact that you can't even divide $x^2$ by $2x$ if you don't have $\frac 12$ available. In your example the divisor $n+1$ has leading coefficient $1$ (we say it is monic), and therefore there is no need to divide by any integer other than $1$, and this works fine with integer coefficients.
As others have observed this is quite a simple problem and can almost be solved by observation if you know what you are looking for. But the polynomial division method will serve for more complicated examples of the same type.