Dear student,
Hydrogen is an unique element of periodic table which can act as metal as well as non metal.
Hydrogen has 1 electron so to be stable , it can gain or lose one electron .
When hydrogen bonded with most electronegative element then it forms a positive ions but when it bonded with less electronegative element then it forms a negative ion.
Regards