Anthracite coal is up to 85.7% carbon by weight the rest is not pure hydrogen but a mix of sulfur, oxygen, nitrogen, and hydrogen. (And yes, that Oxygen lowers the energy density while increasing CO2 release.)
Natural gas is 25% hydrogen 75% carbon.
Burning hydrogen produces water not CO2.
So, while the specific bonds play a role the actual carbon vs. hydrogen content is a major issue.
> Which is why hydrocarbons produce less CO2 per watt than coal.
No. It has nothing to do with water. Coal is a hydrocarbon as well. It has to do with the type of hydrocarbon chains.