During the first wireless setup, Bluetooth pairs the iPhone with the car. The car then gives the iPhone the information it needs to join its Wi-Fi network, and CarPlay starts over that connection. Once the Wi-Fi session is running, the car ends its Bluetooth connection to that iPhone.
Bluetooth still has a job on later drives. The car can use the saved Bluetooth pairing to find the iPhone and start the wireless connection again. If a CarPlay session drops and Wi-Fi can't reconnect quickly, Bluetooth can also help reestablish it.
There are a couple of ways to complete that initial setup. If your car supports both wired and wireless CarPlay, connecting the iPhone by USB can handle the pairing before the phone offers to connect wirelessly on later drives. If you set it up without a cable, Apple tells users to make sure Bluetooth and Wi-Fi are enabled, put the car into wireless or Bluetooth pairing mode and select the vehicle under Settings > General > CarPlay.