The comparison is not quite that easy. The old petroleum infrastructure is more centralized.
You can get electricity almost anywhere, adding a charging station to parking places or garages is far easier and safer than hypothetically laying gasoline pipelines everywhere. So there are more opportunities for partial charging when the car is idle.