The problem GP is talking about is the vast, vast majority of hydrogen today is produced by steam reforming, which is vastly cheaper than electrolysis (around 3x) but produces huge amounts of CO2 (6 tons per ton of hydrogen).
But most industrial hydrogen production is the so-called 'blue' hydrogen. Produced from fossil fuels, because that's a cheaper process than electrolysing water.