Spectrum analyzers are using the Fourier transform algorithm to convert the signal from time-domain (sample) to frequency-domain (spectrum). This is a great video that explains how it works: https://www.youtube.com/watch?v=spUNpyF58BY

Most of the analyzers are using FFT, or Fast Fourier Transform, a heavily optimized version of the Fourier transform, that works on fixed slices of the audio signal (power-of-two lengths, so 2048, 4096, 8192... etc. samples).

One characteristic of this algorithm is that it isn't perfect:

To measure the frequencies of a signal accurately, you need a long slice of the audio signal. However, music is dynamic, a changing mix of frequencies, to measure movement of these you need a shorter slice of the audio signal.

There are other factors to this algorithm, like using different windowing functions, overlapping, etc. I won't go into too much detail here. You can check the effect of these parameters in Voxengo Span's settings.