It is because nitric acid is a strong oxidising agent (because it decomposes to yield nascent oxygenas:2HNO3 →2NO2 + H2O + [O])and it oxidises the hydrogen formed to water.Only 1% dilute and cold nitric acid reacts with magnesium and manganese to liberate Hydrogen gas.
Nitric Acid is a very strong oxidising agent. It oxidizes the Dihydrogen Gas produced during the reaction with metals to Water. That is why, Nitric Acid cannot be used for preparation of hydrogen gas.

However, metals like Magnesium and Manganese still produce Hydrogen Gas but with very dilute nitric acid.
1 1 1