It's not the phone deciding to do it, when the device connects the car is telling it to play. Check your infotainment settings to see if there's a way to turn it off.
Apple doesn't have an official way to prevent it, but I think you could do it with Shortcuts and an automation to pause music triggered by "When CarPlay is connected."
If it's tricky to get it to trigger at the exact time it starts playing, you could even do like:
- Store media volume to a variable
- Set media volume to 0
- Wait 3 seconds
- Stop playing
- Restore original media volume
Apple doesn't have an official way to prevent it, but I think you could do it with Shortcuts and an automation to pause music triggered by "When CarPlay is connected."
If it's tricky to get it to trigger at the exact time it starts playing, you could even do like: