Fossil fuel comes out of the ground with the energy already in it, hydrogen doesn't exist in a free form and the energy must be put into it coming from somewhere else.
Most hydrogen now comes from natural gas at maybe 75-80% efficiency through reforming, then it must be compressed, then it must be burned at similar efficiencies to fossil fuel or used in a fuel cell with slightly better efficiency than ICE.
It's way worse in efficiency than fossil fuels, you could just use the natural gas directly in a combustion engine and be way ahead. Solar/wind/nuclear to electrolysis is even worse, just charge a battery.
Hydrogen is a energy storage mechanism like a battery not a source of energy like fossil fuel.
Look at well to wheel efficiency BEV are far ahead of hydrogen.