Mg has a smaller electronegativity value, so it has a faster reaction rate when it reacts with HCl because elements with lower electronegativities tend to get rid of their electrons. After all, the electrons do not have a strong attraction towards it. Therefore, it ionizes and reacts instantaneously