A molecule is a specific collection of atoms. Sometimes the atoms are the same, like in molecular hydrogen (H2) or oxygen (O2). Often more than one type of atom comes together to make a molecule, like in carbon dioxide (CO2, see figure 1) or water (H2O). Molecules have a specific size and chemical composition.
If a substance has a particular chemical composition, but no specific size, it's not a molecule. This includes table salt, a sodium iodide ionic solid, no definite number of sodium or iodide, just a specific ratio. Also, rocks and minerals have a chemical composition that tends to be close to SiO2, but not quite consistently enough to be called molecules.
Chemical reactions make new molecules by recombining atoms in different ways. Starting a chemical reaction usually takes energy. Then these reactions release energy from forming the chemical bonds which keep the atoms in molecules together.
For an in depth discussion of molecules, please see UC Davis's chem wiki.