Atoms form a new substance by bonding with different atoms.
For example, hydrogen atoms and oxygen atoms bond to form H2O as per this equation:
2H2 + O2 ---> 2 H2O
To understand how to hydrogen and oxygen atoms form water you can write that as:
2 H - H + O - O ---> 2 H - O - H
Each hypen represent a chemical bond.
What is happening is that the H - H atoms and the O - O separate and bond with different atoms: H bonds to O which in turn bonds to other H.
Also, you have to know that chemical bonds are the result of interaction between the electrons of the valence shell of electrons of each atom. This is, valence electrons from O interact with valence electrons of H to form the bond H - O.
The interaction may be in different ways depending on the properties of the atoms: the kind of bonds known are metallic, ionic and covalent.