Molecules form when atoms bond through covalent, ionic, or metallic bonds, sharing or transferring electrons.