They have similar formal expression. For example, let us take harmonic oscillator to explain this.
In theoretical mechanics, the system is described by the Hamiltonian function of position and momentum
$$
H(r,p) = \frac{p^2}{2m} + \frac{1}{2}kr^2,
$$
and we can derive equations of motion for ##r##, ##p## from it.
While the Hamiltonian operator for the same kind of system in wave mechanics is the operator
$$
\hat{H} = \frac{\hat{p}^2}{2m} + \frac{1}{2}kr^2,
$$
where ##\hat{p} = - i\hbar \frac{\partial}{\partial r }##, acting on complex functions of ##r##.
As you can see, the function ##H(r,p)## and the operator ##\hat{H}## look similar, but they are different concepts from different theories. In order to get some interesting results from them, they are used in calculations in a different way.
The form of the Hamiltonian operator is often similar or motivated by the form of some Hamilton function. One often fruitful procedure is that one takes some interesting function ##H(r,p)## (for non-interacting particles in a box, or particle in a central field), changes ##p_a##'s into gradient operators ##\hat{p}_a##'s and takes the resulting expression as operator acting on functions of ##r_a##.
If you are interested in the connections between the functions and the operators, I recommend original Schroedinger's papers in
E. Schroedinger, Collected papers on wave mechanics, Blackie and Son Limited, 1928
Also very interesting view on the connection between original Hamiltonian formalism and Schroedinger's equation can be found in more recent book by theoretical chemist David Cook:
David B. Cook, Probability and Schroedinger's mechanics, World Scientific 2002