The best way to make sure Apple CarPlay doesn’t automatically play music when you connect your phone is to set up a Shortcut. Just pause your music when you connect to your car over Bluetooth (in vehicles like BMWs that have wireless CarPlay) or through CarPlay.