Let $G=(V,E)$ be a graph with a Hamiltonian path $P$. Let $M$ be a matching of $G$ and $N$ be a maximum matching of $P$. Then each component of the graph $H=(V, M\cup N)$ is either a path or a cycle.
Since every vertex, with the exception of possibly one vertex, is matched by $N$, we have :
(i) every component contains edges from both matching and
(ii) at least one end edge of each path component is in $N$.
Therefore, if a component is a cycle then it must contains the same number edges from both matching.
If a component is a path of length one, then it must be a common edge of $N$ and $M$ and hence it contains the same number of edges from both matching.
For other paths, by (ii):
Either one end edge is in $N$ and the other end edges is in $M$ and hence it contains the same number of edges from both matching.
Or both end edges are in $N$ and we can remove one of those end edges and get a component that contains the same number of edges from both matching.
So we can get $M'$ by remove one end edge from each path component of length greater than $1$ with both end edges belonging to $N$.