well, it looks like you have to explain a little better - this seems to apply to a specific situation. is "g" standing for gravity? I believe you are describing this situation: gravity is pulling on some little object of mass "m" attached by a rope and pully to another object of mass "M" that is sitting on a horizontal frictionless table. is this right? well then check it out:
make sure that you understand which things are forces and which things are not. you should put the equation you have right now (the one on the right) into F=ma form. is it now? Nope. this is because "g" is not a force. "g" is an acceleration. how do you make it a force? well, look to the left - forces are masses times accelerations! so if you multiply "g" times a mass, you will get a force.
But which mass do you multiply by? probably little "m" if I'm interpreting the problem the right way. so then you have
gm = a(avg) (M+m). NOW this is force = mass times acceleration. the "gm" is the force provided by the pull of gravity on the little block. and the right side is also an acceleration times a mass, so it is right - and it makes sense too because the M AND the m have to be moved by this force, so their SUM is the mass that is moving, cause it is moving both of their masses!
Anyway, this is pretty much it, good luck!