For the interval $x\leq 2$, the slope of the line is $\frac{6-4}{-4-(-2)}=-1$
For the interval $-2\lt x\lt 3$, the slope of the line is $0$, and it is also clear that the equation of the line in this case would be $y=4$.
For the interval $x\geq 3$, the slope of the line would be $\frac{6-4}{5-3}=1$
We use point slope form of a line i.e. $y-y_{1}=m\times (x-x_{1})$ for each of the interval given in the question, where $m$ is the slope of the line, $(x_{1},y_{1})$ is the point through which the line passes.
For the interval $x\leq 2$, the equation of the line is : $y-4=-1\times (x-(-2))$ $\Rightarrow$ $y=2-x$
For the interval $x\geq 3$, the equation of the line is : $y-4=1\times (x-3)$ $\Rightarrow$ $y=x+1$
Option D is the correct answer.