Both driving a car and using electricity produce several greenhouse gases which can lead to global warming.
Greenhouse gases are gases that, when released into the atmosphere, trap the heat from the sun's energy. Every day the energy from the sun reaches the earth. Some of the energy is reflected back into space and some of the energy is trapped by the earth's atmosphere. Most of the time the energy being trapped by the atmosphere serves to warm up the earth, so that the temperature does not fluctuate dramatically. In this way the atmosphere acts like a greenhouse - trapping the warmth in.
One of the ways that electricity is made is by burning fossil fuels, like coal or fuel. When a fuel is burnt, some of the products are: carbon dioxide, carbon monoxide, and water - all of these gases are greenhouse gases. In a similar way driving a car also burns fossil fuels, and this will produce the same gases.
Before lots of fossil fuels were burnt the greenhouse gases in the atmosphere would have been moderated by the carbon cycle. However, if we burn excess fossil fuels we are producing excess greenhouse gases. This can cause more heat to be trapped by the atmosphere and therefore the global temperature will start to rise - global warming.