How do you calculate the moles and mass of compounds involved in a chemical reaction, such as the reaction of Mg with HCl to produce MgCl₂ and H₂?