What I did was I renamed (in my .bash_profile) the
export M2_HOME=/usr/local/bin/mvn
export M2=$M2_HOME/bin
to
export M3_HOME=/usr/local/bin/mvn
export M2=$M3_HOME/bin
and then used the command (thanks TS!)
$ which mvn
and
$ echo $M2_HOME
And I saw there is a different path in the both so I changed the $M2_HOME
path to be the same as it showed me in the "Which mvn" command. In order to change this path I just edited the .bash_profile file where I had the variable.