Every year, Ohio police officer Greg Ellifritz (activeresponsetraining.net) has a post whose title begins with "Lock Your Damn Doors". In the community he serves, most thefts from homes and vehicles come from ones that aren't locked. In the 2019 post, he says that, in years past, the culprits were usually neighborhood kids. Now, they are adult drug addicts. The kids weren't dangerous; the addicts are.
Keep your doors locked and windows up when you are driving. Even if a carjacker is prepared to break a window, he will try the door handle first. The brief delay, while he adjusts his game plan after finding it locked, gives you an opportunity to react defensively. Driving away should be your first choice.
Active Self Protection on YouTube has several surveillance videos of armed robberies that occurred as the victims were getting out their vehicles after arriving home. The videos are foreign in origin (mostly from Brazil) so I don't know if this is a significant problem here.
Every state has castle doctrine. Even if retreat from a confrontation is required when you are out in public, it's not required at home. There, you can stand your ground. Depending on the state, castle doctrine may also apply to your business, to curtilage which is other parts of your property that you use routinely (e.g. the garage), and to your vehicle when you are inside it. Some states go further with the presumption that an unlawful intruder poses a deadly threat to the occupants of the home. It makes a claim of self defense easier to substantiate. To distinguish between criminals and innocent trespassers (e.g. a meter reader), the intruder must have broken in. If all your doors and windows are locked, an intruder cannot get in without leaving evidence that invokes the presumption.