Balancing Chemical Formulas is like simple mathematic systems of equations
Lets look at your second example:
H2 + Cl2 = HCl
Lets replace H with x, and Cl with y.
the equation would now be
2x + 2y = xy (now I know in math x+y does not equal xy, but bear with me)
This would not be correct. For the equation to be true, both sides must yield the same counterpart. To do this, you'd have to add a coefficient to balance out both sides.
Looking at the equation, you know you have to balance the right side, as the left side is adding two things up to getting only half value. So, we will add coefficient of "2" to xy. This means that the balanced chemical equation will now be H2 + Cl2 = 2HCl