The yellow battery wire should be connected to the vehicle's battery, and the red accessory wire should be connected to the vehicle's ignition switch. This will ensure that the head unit receives power when the ignition is turned on, and that it turns off when the ignition is turned off.
If you are unsure about how to install a head unit in your vehicle, it is best to consult with a professional car audio installer.