You can use gas and other fossil fuels to produce hydrogen, but you can obviously use renewables too, amongst other methods. https://www.csiro.au/en/news/all/articles/2021/may/green-blue-brown-hydrogen-explained
There has been a decent greenwashing campaign to try to disguise that a lot of hydrogen in the hydrogen mix is produced using fossil fuels. This is to try and enable greater use of hydrogen technologies over other solutions, eg EVs vs hydrogen cars, and keep money flowing to the fossil fuel barons. Unfortunately, we do need to be careful when we hear the blanket phrase 'hydrogen', rather than 'green hydrogen' specifically.
This article is from 2021 but I imagine the percentage of grey hydrogen in the hydrogen production mix is still up towards what is stated in the below quote. The context for the quote is in the lead up to the Tokyo Olympics, Tokyo was using hydrogen buses.
Currently, around 95% of hydrogen production is what is called “grey”, including that being used at the Tokyo Olympics. It is made by reacting natural gas with high-temperature steam. This is the cheapest way to manufacture hydrogen but produces loads of CO2. In fact, it has been calculated that producing 1kg of hydrogen by this method will generate 9.3kg of CO2, which is actually more than the 9.1kg of CO2 produced by burning a gallon of gasoline, usually considered to have a similar energy value.
Damn, gives a good perspective to the size of that Wedgie!