Even if electricity generation is from coal, EVs produce less CO2 than ICEs, because big power plants are much more efficient than small engines. Plus all the other benefits they have, especially in cities.
This is quite disputed still, mainly because of the high weight of the batteries and the large energy cost of manufacturing these batteries. The studies I'm aware of, pretty much agree on that for 100% coal based electricity, ICEs are better, and for 100% renewables EVs are better. The dispute is at what percentage EVs become better.