Sorry, I forgot that.
Either $\displaystyle x+4=0$
or
$\displaystyle x^2-5x+8=0$
If $\displaystyle x+4=0$, then we know $\displaystyle x=-4$.
What if $\displaystyle x^2-5x+8=0$. $\displaystyle x$ is an imaginary number. How did it become -4.
My maths teacher also did like this for one question.
It's something like (An expression)X(Another expression)=0.
He made the solution only if first expression=0. He did not make the solution if another equation is 0.
A variable can only take one value at a time. If $\displaystyle x=-4$, the whole product becomes zero. That means it is a solution. The second equation cannot be solved over the reals, so the equation only has one real solution.
if the solution to $x^2-5x+8=0$ then clearly $x\neq -4$ as $(-4)^2-5(-4)+8=44$
The solution is satisfied if either factor is 0, so in this case either
$x=-4$ OR $x=\dfrac 1 2 \left(5 \pm \imath \sqrt 7\right)$
your professor probably ignored the other factor when he/she did what they did because they were only interested in real solutions. I don't know, I wasn't there.