I am looking at this problem in Morin's Introduction to classical mechanics:
6.1. Moving plane A block of mass $m$ is held motionless on a frictionless plane of mass $M$ and angle of inclination $θ$ (see Fig. 6.8). The plane rests on a frictionless horizontal surface. The block is released. What is the horizontal acceleration of the plane?
Here is the more detailed diagram associated with the solution:
The quantities $x_1$ and $x_2$ represent the horizontal displacement of the plane and the block in their respective directions. Later on I switch to $q_1$ and $q_2$ to keep my sanity as I go through the Lagrangian and Hamiltonian.
The proposed solution sets out the Lagrangian in terms of the kinetic energy
$$ K=\frac12M\dot q_1^2 + \frac12 m ((\dot q_1 + \dot q_2)^2\tan^2(\theta) + \dot q_2^2) $$
and gravitational potential
$$ V=-mg(q_1+q_2)\tan(\theta) $$
where I have replaced $x_i$ in the diagram with $q_i$.
This yields the Lagrangian
$$ L=K-V=\frac12M\dot q_1^2 + \frac12 m ((\dot q_1 + \dot q_2)^2\tan^2(\theta) + \dot q_2^2)+mg(q_1+q_2)\tan(\theta) $$
which, when processed with the Euler-Lagrange equations gives a solution ('after a little simplification')
$$ \ddot q_1=\frac{mg\sin(\theta)\cos(\theta)}{M+m\sin^2(\theta)} $$
(I did my best to process it with Sympy in python and got that solution as
$$ \ddot q_1=\frac{mg\tan(\theta)}{M \tan^2(\theta) + M + m\tan^2(\theta)} $$
I think I see why it is equivalent after dividing top and bottom by $\cos^2(\theta)$, so I feel good that I have things set up right.)
To crosscheck things I also wanted to apply the Hamiltonian procedure, and so after replacing the $\dot q_1=\frac{p_1}{M}$ and $\dot q_2=\frac{p_2}{m}$
I had the Hamiltonian $$ H=K+V=-mg(q_1 + q_2)\tan(\theta) + \frac12 m ((p_2/m + p_1/M)^2\tan^2(\theta) + p_2^2/m^2) + \frac12 p_1^2/M $$
But processing this with Hamilton's equation $\dot p=-\frac{\partial H}{\partial q}$
I think that should mean that $\frac{\ddot q_1}{M}=\dot p_1=mg\tan(\theta)$ which (I think?) is not the same as the one suggested in the solution in the book. This seems to be what I get both by hand and symbolically with Sympy.
So at the moment (no pun intended) I'm stumped as to what I'm doing wrong. Can I not use the time derivative of the momentum to check the acceleration like this?

The misconception OP is having is the approach to the Hamiltonian method.
The Hamilton equation $\dot{p_i} = - \frac{\partial H}{\partial q_i}$ does not apply to the "ordinary momentum" $p_i$. It instead applies to the canonically conjugate momentum, which is defined as $p_i = \frac{\partial L}{\partial \dot{q_i}}$.
In simple cases, the part of the Lagrangian that depends on $\dot{q}_i$ is $\frac{1}{2} m_i \dot{q_i}^2$, so the canonically conjugate momentum is indeed $m q_i$. In this case, however, the canonically conjugate momenta are
$p_1 = M \dot{q_1} + m \tan^2\theta (\dot{q_1} + \dot{q_2})$
$p_2 = m (\dot{q_2} + \tan^2 \theta (\dot{q_1} + \dot{q_2}))$
As you can see, there is some annoying entanglement going on here between the two variables. This is reflected by the fact that energy depends on $(q_1 + q_2)^2$, in part.