Since many folks spend a considerable amount of time in their vehicles—either commuting to and from work or in those cases where the vehicle is their workspace—it seems prudent to be aware of one's surroundings while driving.
Let's talk preparation:
Don't look like a victim—make a criminal wait for an easier target. Keep the doors locked and the windows up. Don't leave valuables on the seat or in plain view—a purse or laptop case or even a backpack on the front or back seat, is a tempting target. A thief could launch a brick through the window, grab it and go; it would take maybe 5 seconds, max. Using the trunk may take a few extra seconds, but it is more secure.
If you are carrying a firearm, make sure it is both accessible and secured. Resist the temptation to unholster or take it out of the console/glovebox, and tuck it under your leg or lay it on the seat. Any sudden movement of the vehicle, like getting bumped from behind or if the thug in front of you slams on the brakes to make you hit him, and the gun may go flying. Keeping it holstered means if you get pulled from the vehicle or get out on your own accord, the gun goes with you. If you have a designated car gun in addition to your carry gun, make sure it is secured so it cannot be stolen, like in a lock box wired to the car.
Don't get fixated on things—stay alert at all times. Distraction may well be part ofthe hoodlum's plan. Scan left, right, check all the mirrors and be on the lookout for anybody approaching, especially from your "blind" spots (left rear and right rear).
An easy place for a smash-and-grab or a carjacking is at a stop light or stop sign. Try to avoid being "boxed in"—leave room in front of you to simply accelerate and turn the wheel to get away. If you are too close to the vehicle in front of you, you are limited as to where and how much you can move the vehicle. Avoid being trapped between a median, high curbs, etc. and other traffic. Look for a way out, so if a bad guy appears at your window, you can just steer left or right 90 degrees and floor it.
When it is time to park, make a loop first, so you can check for thugs watching the parking lot. Do a good scan before you exit.
At night, keep a flashlight in your hand. When returning to the car, an indirect path may allow a scan of things around the vehicle, like crouched or hidden bad guys or somebody hiding in your back seat. Many newer cars activate headlights and dome lights when the "unlock" button is pressed, so do this earlier rather than later to help with the scan. And don't be afraid to hit that "Panic" button if the need arises.
Like most every other situation, your level of alertness is critical to spotting potential threats so they can be countered or avoided. Stay alert, stay alive.