m by default installs mongodb to /usr/local/m/versions, from
which it can see what you have currently installed, and activate previously installed versions of mongodb when m <version> is invoked again.

Activated mongodb versions are then installed to the prefix /usr/local, which may be altered via the M_PREFIX environment variable.

To alter where m operates simply export M_PREFIX to whatever you prefer.