Is it true that $\dots$ $$ \left| y \right| = \begin{cases} y \hspace{1cm} y \geq 0 \\ -y \hspace{0.7cm} y < 0 \end{cases} $$
I'm a little bit confused with the second case, where $|y| = -y$ then $y<0$, for example : $$ \left| 2x-4 \right|=-(2x-4) $$ if we assume that $ y=2x-4 $ then $$ \begin{align*} y&<0 \\ 2x-4&<0 \\ 2x&<4 \\ x&<2 \end{align*} $$ in the other way, we can solve it like this $$ \begin{align*} |y| \geq 0 \\ |2x-4| \geq 0 \\ -(2x-4) \geq 0 \\ 2x-4 \leq 0 \\ x \leq 2 \end{align*} $$
why is it giving the different answers?

You should train to read formulas without reference to specific variables. The definition $$ |x|=\begin{cases} x & x\ge0 \\[4px] -x & x<0 \end{cases} $$ it is meant that
You should also avoid using a variable with two different meanings in the same statement.
It seems that you want to see when $|2x-4|=-(2x-4)$. According to the definition, this happens if and only if
Why the second case? Because $0=-0$. On the other hand, if $2x-4>0$, then we cannot have $(2x-4)=-(2x-4)$, because one term is positive and the other one is negative.
One might make the initial definition more symmetric by declaring $$ |x|=\begin{cases} x & x>0 \\[4px] 0 & x=0 \\[4px] -x & x<0 \end{cases} $$ but you can also note that $$ |x|=\begin{cases} x & x>0 \\[4px] -x & x\le0 \end{cases} $$ would be a completely equivalent definition.