I feel like mastering shouldn't be a factor in this, because yeah some CDs where obviously terribly done to sound louder but that isn't a quality of the format itself
It's capitalism making things worse again.
CDs improved over LPs in dynamic range, frequency response, error correction, replayability, stereo separation, and noise floor. They also, at scale, became much cheaper to manufacture and distribute.
But if the engineers, producers and marketers insist on not using the technical capabilities, or deliberately degrading them to chase perceived loudness, there's nothing the purchaser can do except complain.
What matters is the final result not the parts.