The energy of **a photon** is directly proportional to its (angular) frequency:
$$
E=\hbar \omega.
$$
The energy of a classical mechanical wave is, however, proportional to the square of $\omega$:
$$
E=\frac{1}{2}\mu A^2\omega^2 \lambda
$$
**per wavelength**.

I struggle to see why there is $\omega$ in one equation but $\omega^2$ in another.

It is quite mysterious, though, because the $E$ in two equations mean different things. **How many photons per wavelength do we have?**