What Hamilton discovered is a mathematical "Hamiltonian formalism". It was applied to those parts of physics which were known at the time of Hamilton: classical mechanics and optics. There was no slightest reasons at the time of Hamilton to suspect that matter on small scale does not obey the laws of classical mechanics.
That this is so, is a late 19s century discovery. However it turned out that Hamiltonian formalism is so general that it applies to quantum mechanics as well. Thus many equations written by Hamilton (and not only by Hamilton, but by other late 18s and early 19s century researchers in mechanics, like Lagrange) actually apply, if they are correctly interpreted.
Similarly, Calculus, a mathematical tool invented in 17s century serves not only mechanics, but all physics discovered later. But nobody claims on this ground that Newton and Leibniz discovered all physics which was discovered later.
EDIT. Of course this is a miracle that the same mathematical tool applies to a very wide class of phenomena in the universe, including those which were not known when the tool was invented/discovered, but this is the way our world is created.