molecules are groups of atoms that stay together because of chemical bonds. These can be covalent bonds, where electrons are shared between atoms or ionic bonds where the difference in (positive or negative) charge between ions causes them to attract. To summarize, its because of chemical bonds.