>> The “dirty electricity” angle is less obvious to me.
A power plant typically gets about 60% of energy from a fossil source. A car does about 30%. So even if the electricity comes from say coal, it's still more efficient than buying gas in a car engine.
Of course, these days, it's likely that a substantial portion (up to 100% in some cases) is not "fossil electricity" but rather comes from solar, wind, hydro etc. Ie "clean" electricity.