This equation is easily balanced by placing the coefficient '2' in front of molecule (HCl) to form the balanced equation (Mg) + 2(HCl) ⟶ (MgCl2) + (H2). The equation (Mg) + (HCl) ⟶ (MgCl2) + (H2) is clearly unbalanced because on one side, there is only 1 hydrogen atom, but on the other side, there are 2 (also unbalanced Chlorine, but they both come from the same compound so this becomes really simple to balance).
you need to make sure (because of the law of conservation of matter-matter cannot be destroyed or created) that if you have a definite amount of something on one side, you have an equal amount of it on the other side. So, balancing an equation is just like balancing the x in an algebraic equation. You can read my explanation below to get an idea for this, but basically, the coefficient is just telling the chemist how much of a specific atom, molecule or compound it takes to gain the desired product. It gives us a way to measure a reaction and use stoichiometry to gain the exact amounts desired of a specific product.
The coefficient in a balanced equation is an idea the concept of telling the chemist that if the atoms, molecules and compounds are balanced, there are balanced amounts of the atoms, molecules and compounds on the other side in the product.