When acid reacts with metal , a metal salt is formed and hydrogen gas is liberated.Same happens with magnesium, being a metal when it reacts with sulphuric acid, magnesium sulphate is formed and hydrogen gas is liberated.
Mg(s) + H2SO4(aq) MgSO4(aq) + H2(g)