Randomly Spotify started to only play music in CarPlay with the phone screen on and the Spotify app open on the phone. If I tried to go to the home screen, another app, or lock my iPhone then music stops playing. Tried turning off car mode on the Spotify iPhone app but all it did was make the screen lock and stop playing.
It's potentially possible that your car has settings enforcing safety that are causing these problems. Both sides, Spotify and often the car, place restrictions to ensure road safety. I've noticed this problem in cars with digital interfaces.