Yesterday, for the Atwood's machine, the combined our two force equations to eliminate the tension, resulting in:
Mg - mg = (M + m) a
We could have obtained this right away by treating the two boxes as one combined system, and applying Newton's second law to that system.
Force responsible for the motion: Mg
Force holding the system back: mg
The net force, Mg - mg, equals the combined mass times the acceleration.