Both convert a 1D signal into a 2D complex map, aiming at unveiling transient features of the data. Both use a functional microscope: the signal $s(t)$ is analyzed through variations of a single template function $\rho(t)$ with two parameters $p$ and $q$.
So the signal is analyzed through the form:
$$R_s(p,q) = \int s(t) \rho^*_{p,q}(t) d\cdot$$
which is 2D (the differential increment $d\cdot$ can be specific).
With the spectrogram, $\rho$ is a fixed (non-zero sum) window, and $\rho_{p,q}$ is the same window, shifted by $p$, and modulated by a frequency proportional to $q$.
With the scalogram, $\rho$ is a fixed zero-mean function (a wavelet), and $\rho_{p,q}$ is the same wavelet, shifted by $p$, and dilated by a factor proportional to $q$.
Why they have those properties is another story.