In the above diagram, both the surfaces are frictionless. The force exerted by $m_1$ perpendicular to the inclined plane $m_2$'s surface is $m_1g\cos\theta$, and the horizontal component of that force is $m_1g\cos\theta \sin\theta$. Now if I want to find the acceleration of $m_2$, why is $$a = \frac{m_1g\cos\theta \sin\theta}{m_1+m_2}$$ wrong? To calculate the acceleration wouldn't we have to consider the mass of the entire system rather than only $m_2$?
Additional question: since the inclined plane $m_2$ is moving to the right with an acceleration, shouldn't $m_1$ "fall" and land on $m_2$ again? what causes it to stick to $m_2$?