Why hydrogen gas plus oxygen gas equals liquid water?

It just does, the same way 2+2=4.

you need to get past this in order to learn about more advanced topics in chemistry