In a chemical reaction no atoms are created or destroyed. They are only rearranged to make new substances, so the total mass of the products is equal to the total mass of the reactants. This is the principle of conservation of mass. A chemical equation must show this, so it must have the same number of atoms of each element on both sides. We say the equation is balanced.
To balance an equation, count the atoms of each element on the left and on the right. Then write a large balancing number in front of a formula. You must never change the small lowered numbers inside a formula (the subscripts), because that would turn it into a different substance. For example, H2O2 is hydrogen peroxide, not water.
Worked example: magnesium burns in oxygen, giving the word equation magnesium + oxygen → magnesium oxide. The symbol equation Mg + O2 → MgO is not balanced because there are two oxygen atoms on the left and one on the right. Writing 2MgO gives two oxygen atoms on the right, then 2Mg gives two magnesium atoms on the left. The balanced equation is 2Mg + O2 → 2MgO, with 2 magnesium atoms on each side.
Another example is CH4 + 2O2 → CO2 + 2H2O. The 2H2O contains 4 hydrogen atoms, which matches the 4 hydrogen atoms in CH4. At Higher tier you also write half equations, which show only one reactant changing, for example Na → Na+ + e-.