Its not just about losing or gaining energy, its about the costs involved on both sides of the equation.
If you can produce electricity from say solar or wind cheap enough, then using that electricity for electrolosis of water to produce hydrogen to run cars would work, even though you are losing energy in the process. What you are achieving is transforming energy from a non usable form to a usable form. ie it would not make sense to run a car on wind power, but using wind power to make electricity to split water so a car could burn hydrogen to run would make sense, if, and its a big if, if it is economical to do so.