Why should one choose the maximum as reference for power-to-decibel conversion? I have seen that one converts the amplitude to decibels through:
$\text{dB(S)}=10 \text{log}_{10} \big(\text{S/ref}\big)$, where $\text{S}$ is the output of a STFT and ref the reference value for the logarithmic scale, i.e. the value that should be mapped to decibel, right?

However, I've seen implementations with $\text{ref = max(S)}$
and I do not understand why. Can someone clarify on that?
dB is a power ratio, so when we see units in dB we are seeing units on a relative scale. The reason that a 0 dB reference is so common is because this is simply normalizing the number scale to 1. $10Log(1) = 0$ dB

This is similar to using 100% (1) instead of absolute numbers.