Compression can definitely help with that, but so can automating the volume knob. If it were just about keeping volume consistent, they would compress different tracks differently (which they do).
They overly compress the master channel specifically to make it very loud, and there's dozens of interviews with engineers that are frustrated with it.