Where does molecular hydrogen in the atmosphere come from?
Besides man-made sources, hydrogen can be produced naturally through a process called serpentization.  Mafic and ultramafic rocks, which are rich in magnesium and iron silicates, react with water to produce a variety of breakdown products summarized in the Wikipedia article on serpentine

Serpentinization is a geological low-temperature metamorphic process involving heat and water in which low-silica mafic and ultramafic rocks are oxidized (anaerobic oxidation of Fe2+ by the protons of water leading to the formation of H2) and hydrolyzed with water into serpentinite. Peridotite, including dunite, at and near the seafloor and in mountain belts is converted to serpentine, brucite, magnetite, and other minerals — some rare, such as awaruite (Ni3Fe), and even native iron. In the process large amounts of water are absorbed into the rock increasing the volume, reducing the density and destroying the structure.[1]


The density changes from 3.3 to 2.7 g/cm3 with a concurrent volume increase on the order of 30-40%. The reaction is highly exothermic and rock temperatures can be raised by about 260 °C (500 °F),[1] providing an energy source for formation of non-volcanic hydrothermal vents. The magnetite-forming chemical reactions produce hydrogen gas under anaerobic conditions prevailing deep in the mantle, far from the Earth's atmosphere. Carbonates and sulfates are subsequently reduced by hydrogen and form methane and hydrogen sulfide. The hydrogen, methane, and hydrogen sulfide provide energy sources for deep sea chemotroph microorganisms.[1]

Roughly speaking, the magnesium-bearing component of the mafic/ultramafic rock is basic and undergoes acid-base reactions with water, generating no hydrogen (but possibly producing magnesium hydroxide, which indicates said basic conditions).  The iron-bearing components, by contrast, are reducing, especially under the basic conditions associated with the magnesium compounds, and they do generate hydrogen:

Serpentine is the product of the reaction between water and fayalite's ferrous (Fe2+) ions. The process is of interest because it generates hydrogen gas:[2][3]


$3 \text{Fe}_2\text{SiO}_4 + 2 \text{H}_2\text{O} → 2 \text{Fe}_3\text{O}_4 + 3 \text{SiO}_2 + 2 \text{H}_2$


The reaction can be viewed simplistically as follows:[4][5]


$6 \text{Fe(OH)}_2 → 2 \text{Fe}_3\text{O}_4 + 4 \text{H}_2\text{O} + 2 \text{H}_2$.

In addition, in the presence of carbonates and sulfates the reduction process can also produce methane and hydrogen sulfide.  The references cited in this passage explore these processes as sources of raw material and chemically stored energy for undersea life both in Earth and in subterranean ocean worlds elsewhere in the Solar System.
Cited references:
1.
&quot;Serpentinization: The Heat Engine at Lost City and Sponge of the Oceanic Crust&quot;.  Link
2.
&quot;Methane and hydrogen formation from rocks – Energy sources for life&quot;. Retrieved 6 November 2011.  Link
3.
Sleep, N.H.; A. Meibom, Th. Fridriksson, R.G. Coleman, D.K. Bird (2004). &quot;H2-rich fluids from serpentinization: Geochemical and biotic implications&quot;. Proceedings of the National Academy of Sciences of the United States of America. 101 (35): 12818–12823. Bibcode:2004PNAS..10112818S. doi:10.1073/pnas.0405289101. PMC 516479. PMID 15326313.
4.
Russell, M. J.; Hall, A. J.; Martin, W. (2010). &quot;Serpentinization as a source of energy at the origin of life&quot;. Geobiology. 8 (5): 355–371. doi:10.1111/j.1472-4669.2010.00249.x. PMID 20572872.
5.
Schrenk, M. O.; Brazelton, W. J.; Lang, S. Q. (2013). &quot;Serpentinization, Carbon, and Deep Life&quot;. Reviews in Mineralogy and Geochemistry. 75 (1): 575–606. Bibcode:2013RvMG...75..575S. doi:10.2138/rmg.2013.75.18.