Let us rewrite the function as :
$f(x) = \begin{cases} -(x-1)-(1+x), & \text{if }x\leq -1\\ -(x-1)+(1+x), & \text{if }-1 < x\leq 1 \\ +(x-1)+(1+x), & \text{if }1 < x \end{cases}$
Hope it clears your doubt. If not, then take a value for each of the three intervals, put in the formula and convince yourself that it is correct.