There is an option in Apple Music to equalize the volume between tracks, so that all of the songs you're listening to are played at relatively the same volume. Without this option, if you have a playlist made of songs by various artists, from various albums, you may need to reach for the volume knob after each song - just like it happens on TV when movies are interrupted by commercials. Apple's app scans the tracks to find their average loudness and then adjusts the volume accordingly.
But this doesn't alter the songs themselves. It only works at global level, meaning it turns the main volume up or down. It makes the entire song louder or quieter, not just parts of it. If there's dynamic compression in a song, then it's actually in the file to begin with, it's not added during playback.
Now, whether the dynamic compression is added by the streaming service provider, or by the bands/producers, is debatable. Personally, I tend to give the streaming services the benefit of the doubt and to blame the producers, but I could be wrong.