Math atoms of type op, bin, and rel are (depending on what surrounds these math atoms) generally surrounded by whitespace governed by the parameters \thinmuskip, \medmuskip, and \thickmuskip, respectively. The default values of these parameters in the article document class are 3mu, 4mu plus 2mu minus 4mu, and 5mu plus 5mu. (mu is defined as 1/18 of the width of the letter "M", aka \emspace.) In words, \thinmuskip has a fixed value (it's a "length" parameter in TeX jargon), \thickmuskip has a stretch component but no shrinkage component (its minimal value is 5mu and its maximal value is 10mu), and \medmuskip has both a stretch and a shrinkage component (it's a "glue" parameter in TeX jargon; its minimal value is 0mu and its maximal value is 6mu).
You've chosen to make the \mg macro have type math-bin. As a result, the amount of whitespace around the symbol can be as little as 0mu, i.e., no space at all.
My advice to you would be to not touch the value of \medmuskip, as it's used in all kinds of places and calculations. In view of the facts that (a) \mg is supposed to play a role akin to that of \mid, (b) \mid is defined as having type math-rel, and (c) \thickmuskip has no shrinkage component, I would assign math-rel status to \mg as well.