It takes a certain amount of energy for water to exist as water, a certain amount of energy for oxygen to exist as oxygen, and a certain amount of energy for hydrogen to exist as hydrogen
The amount of energy it takes for water to keep being water is less than the sum total of the energy it takes for oxygen and hydrogen to keep being themselves.
When you burn hydrogen, it combines with oxygen in the air and makes water. But that requires less energy to exist, so where does the excess energy go? It's released as heat.
To split water back into hydrogen and oxygen, you have to re-add that same amount of energy again.
Hydrogen as a fuel isn't so much a source of energy as a store of energy. A battery doesn't make energy. You charge it with energy so that you can retrieve that energy later. Similarly, a big power plant electrolyses a bunch of water and makes a bunch of hydrogen. Later, you can use that hydrogen in your car without having to be connected to the big power plant that made it.
this is all probably largely wrong and you should ignore it chemistry SUCKS