I am not completely sure if its the codec Apple uses that is making the difference or if it is because the source is lossless, but bass sounds punchier and instrument separation is much better with Apple Music compared to Spotify's best quality.
I was really looking forward to Spotify's lossless that was announced (I think it's called Spotify HQ?), but I haven't heard about that in a long time.
Edit: If you plug in your Airpod Max with a hardwire cable, the difference is even more noticeable, even with iPhone's internal DAC.
Also want to clarify that the differences and not so pronounced that you will be able to tell right away, but if you listen to Apple Music for a while and try to listen to the same song on Spotify, it will not sound the same. It's one of those cases where you don't know what you don't know till you know it once.