Suppose $q={\{q_i\}}_{i=1}^n$ is the set of generalized coordinates of a dynamical system. $L(q,\dot q,t)$ is the Lagrangian of the system. Now we make coordinate transformation $Q_i=Q_i(q,t)$. Then the new Lagrangian,
$$\tilde L(Q_i,t)=L(q_i(Q,t),\dot q_i(Q,\dot Q,t),t).$$
The above equation comes by just change of variables.
And the new Lagrange's equations are just $$\frac{d}{dt}\frac{\partial\tilde L}{\partial\dot Q_i}-\frac{\partial\tilde L}{\partial Q_i}=0.$$
Now coming to Hamiltonian formulation. We make phase space transformation. Let $H(q_i,p_i,t)$ be the Hamiltonian of the system. $$Q_i=Q_i(q,p,t)\text{ and }P_i=P_i(q,p,t).$$
But these transformations does not preserve the form of the Hamilton's equations of motion. There are only small subset of phase space transformation (canonical transformations) which preserves the form of Hamilton's equation of motion but with a new Hamiltonian $$K(Q,P,t)=H(q_i(Q,P,t),p_i(Q,P,t),t)+\frac{\partial G}{\partial t}$$
where $G$ is the generating function of the canonical transformation.
I want to know that in Hamiltonian why can't we directly apply change of variables as we have done in Lagrangian?
I have seen answers to the related question in this site, but they use heavy mathematics and also use differential geometry to explain the reasoning.
I am beginner to classical mechanics. I have not studied these advanced mathematics.
May someone please explain the reason in somewhat simpler terms, so that I will get some intuition.
The related question which is given in the comments by Qmechanic, I have read it already. But it uses lots of differential geometry and advance mathematical concepts. But I am beginner to theoretical classical mechanics. That's why I want to get some intuitive idea about it.