You should read up on thermodynamic laws...
Electricity does have a lot more optimization opportunity, though, whereas those liquid fuel processes are pretty much at their optimum already. A local solar panel DC'ing straight into your car's batteries is going to be pretty good compared to the "generic" pipeline I gave you above. (On the other hand, it can go the other way, too; if your electricity notionally passed through something like a gravity storage step, you lost more there too.) Although from what I've gathered from looking at solar setups, most local solar setups won't actually do that, so it's an optimization yet to be done rather than something all roof-mounted solar panels already do.