This answer should be seen as a complement to the other answers.
A third degree curve $y=f(x)=x^3+\cdots$ is known to have two possible shapes

according to the fact that its derivative has sign changes (necessarily a "$+ - +$" pattern) or not (a simple "+" pattern), i.e., respectively two real roots $a,b$ or no real root. [we leave apart the limit case of one real root]. In the first case, we have a relative maximum in $(a,f(a))$, followed by a relative minimum in $(b,f(b))$. There will be 3 real roots if $(a,f(a))$ is above $x$ axis and $(b,f(b))$ is below $x$ axis ; this is equivalent to say that
$$f(a)f(b)<0$$
This condition has to be expressed in terms of parameter $m$.
I will use for that a method that is classical, but necessitates to know what a resultant is (explanations below). It suffices to write twice the coefficients of $f$, ans 3 times the coefficients of $f'$, with a shift for the first one and two shifts for the second one
$$Res(f,f')=\begin{vmatrix} 1& - m - 2& m^2 + 1& -1& 0\\
0& 1& - m - 2& m^2 + 1& -1\\
3& - 2m - 4& m^2 + 1& 0& 0\\
0& 3& - 2m - 4& m^2 + 1& 0\\
0& 0& 3& - 2m - 4& m^2 + 1\end{vmatrix}=0\tag{2}$$
which is identical to
$$3m^6 - 4m^5 + 6m^4 - 22m^3 - 9m^2 + 26m + 23=0$$
(the very same polynomial found by Claude).
Explanation about the calculation : the nullity of the resultant $Res(f,g)=0$ of 2 (parametric) polynomials $f$ and $g$ is a necessary and sufficient condition for these polynomials to have a common root ; here in the case $g=f'$ ; $f$ and $f'$ have a common root if and only $f$ has a double root. It is known to be a limit case between cases "a single real root" and "3 real roots". The sign of this resultant will change once we have crossed the case $R(f,f')=0$.
The resultant $R(f,g)$ can be computed in (at least) two ways :
up to a factor, it is the the product of values of $f$ computed at the roots of $g$, which is formula (1)
as the determinant computed above (in (2)) .
Remark : $Res(f,f')$ is called the discriminant of $f$ : it generalizes the discriminant of a a second degree polynomial $ax^2+bx+c$ for which the corresponding resultant is :
$$\begin{vmatrix} a& b& c\\
2a& b& 0\\
0& 2a& b\end{vmatrix}=-a(b^2 - 4ac)$$
where we recognize our classical $b^2-4ac$.