Explain why ionic compounds are formed when a metal bonds with a nonmetal, but covalent compounds are formed when two nonmetals bond.
Ionic compounds are formed when the interaction between atoms results in a transfer of electrons, resulting in the atoms possessing a positive and negative charge, which then attracts the component atoms. Elements on the left of the Periodic Table readily lose electrons; those on the right readily gain them. Particularly, columns 1 and 2 of the Table contain the families of the alkali and alkaline earth metals; these share similar properties in their outer electron configuration, whereby losing electrons results in a more stable configuration, namely, the "noble gas" configuration. Column 17 on the right hand of the Table contains the family of halogens; these share the similar property of gaining electrons to secure atomic stability. The interaction of metals and halogens results in the creation of ionic bonds.
With a few exceptions, elements that are not metals are considered to be non-metals.
Covalent compounds are created when non-metal atoms share electrons amongst themselves to attain that outer shell "noble gas" stability.