In classical mechanics, Newton's Second Principle of Dynamics states that the time derivative of the momentum of a system is equal to the resultant of the external forces,
$ \dfrac{d \mathbf{Q}}{dt} = \mathbf{R}^e $.
It's quite easy to prove that the momentum van be written as the product of the total mass of the system and the velocity of its centre of mass, $\mathbf{Q} = m^{tot} \mathbf{v}_G$. If the system is close (i.e. doesn't exchange mass with the environment, so that its mass is constant in classical mechanics), it's possible to write the Second Principle of Dynamics as
$ m^{tot} \dfrac{d \mathbf{v}_G}{dt} = \mathbf{R}^e \qquad$ i.e. $\qquad m^{tot} \mathbf{a}_G = \mathbf{R}^e $.
Before going on, please remember that force, acceleration (and velocity and position) are vector quantities and the Second Principle of Dynamics is a vector equation. In a 2D problem, like the one depicted in the image, you need to write down two components, here let's call them $x$ in the horizontal direction, and $y$ the vertical direction
$x: \quad m^{tot} a_{G,x} = F$
$y: \quad m^{tot} a_{G,y} = N_y - m^{tot} g$,
being $m^{tot} = m + M$ the total mass of the system, $F$ the horizontal external force applied, $N_y$ the normal reaction acting to the lower surface of the triangle due to the presence of the horizontal frictionless surface where the system is sliding, and $g$ the gravity field.
From the first equation, you can readily get the horizontal component of the acceleration of the centre of mass
$ a_{G,x} = \dfrac{F}{m^{tot}} = \dfrac{F}{m + M}$,
while in the y-equation you have two unknowns, $N_y$ and $a_y$, so that you need another independent equation to solve the problem.
In general the reaction $N_y$ and the weight of the system do not cancel out.
TODO: solve the problem for $a_{G, y}$