My 2016 does this as well. I tried everything and the only thing that gets it back to normal is a stopping and restarting the car. When it happens, it just consistently reboots to the carplay screen, connects, disconnects, over and over. It will never play audio except from the FM radio until I stop and restart the car.....which has always fixed it. I had it happen enough times that I started screwing with it and can almost make it happen whenever I want. I think it has to do with plugging the phone in while everything is still initializing when you first turn the car on.
The best way I have found to avoid it is I wait until I am driving down the road before I plug my iPhone in. Where I park (at work & home), I put it in reverse first to either back out of my space or back away from the garage door. I think the initial infotainment boot up, switching to the backup camera, and then back to the infotainment screen when I put it in Drive, combined with the plugging in of the phone is just too much for it sometimes and it wigs out. I can intentionally make it happen probably 80% of the time if I wanted. If I wait until I pull out onto my street or I'm half way out of the parking lot at work, then plug it in, I never have an issue. So thats what I do. Not ideal obviously, but its been a pretty easy workaround.