The exact algebraic answer is:
$$n\equiv \frac {p-1}{2}$$
where, $\thinspace p\mid 4k^2+1\thinspace .$
Here, I have no knowledge that the number of all the factors of $4k^2+1$ can be found by an algebraic formula that depends on $k\thinspace .$
To get the general solution to the problem, we usually apply (as far as I know) $2$ methods: subtracting a polynomial from a fractional expression that makes the numerator a constant and the Discriminant method. Both methods yield the same result. I prefer the $\Delta$ method.
You have:
$$\begin{align}&\frac{n^2 + k^2}{2n+1}=m, \thinspace m\in\mathbb Z\\
\implies &n^2-2nm+(k^2-m)=0 \\
\implies &\Delta_n=4m^2-4k^2+4m\\
&\thinspace\thinspace\thinspace\thinspace\thinspace\thinspace\thinspace\thinspace=(2m+1)^2-(4k^2+1)\\
&\thinspace\thinspace\thinspace\thinspace\thinspace\thinspace\thinspace\thinspace=x^2, \thinspace x\in\mathbb Z\thinspace.\end{align}$$
This leads to the factorization:
$$(2m-x+1)(2m+x+1)=4k^2+1$$
Since the polynomial is symmetric with respect to the sign of $x$, without loss of generality, we have:
$$n=\frac{2m-x}{2}\implies x=2m-2n$$
This yields, unique factorization in terms of $m$ and $n\thinspace :$
$$\bbox[5px,border:2px solid #C0A000]{\begin{align}(2n+1)(4m-2n+1)=4k^2+1\end{align}}$$
We observe that, the number of pairs $(m,n)$ will vary depending on what the odd factors of $4k^2+1$ are.
Let $p=2n+1$ be a possible factor of $4k^2+1\thinspace.$
Then we have:
$$\begin{align}&p(4m-p+2)=4k^2+1\\
\implies &2m+1=\frac {4k^2+p^2+1}{2p}\end{align}$$
Since, $p$ is odd and $2p\mid 4k^2+p^2+1$, this implies that we need only the restriction $4\not\mid 4k^2+p^2+1\thinspace .$
Thus, we obtain the necessary and sufficient condition: $p\mid 4k^2+1\thinspace.$
Finally, we can write a closed-form formula for $n$, that includes all possible numbers:
$$n\equiv \frac {p-1}{2}$$
where, $\thinspace p\mid 4k^2+1\thinspace .$
This completes the answer.