Atoms in our planet are not by themselves, they are joined at least to another atom through a chemical bond. Bonds allow atoms achieve a stable electron configuration, similar as the noble gases, which are mostly not joined to other atoms.
The more important kind of bonds are Ionic and Covalent.
Is formed between atoms from the groups IA, IIA (metals) and VIA, VIIA (non metals). In this bond, metals donate one or more electrons to the non-metals leading to form ions, one of them positively charged (cation) and the other with negative charge (anion).
For example, common table salt is Sodium Chloride. When Sodium (Na) and Chlorine (Cl) are combined, the sodium atoms lose an electron, forming cations (Na+), and the chlorine atoms gain an electron to form anions (Cl–).
Na + Cl = Na+ + Cl– = NaCl
Most of the Ionic compounds in our planet are in the solid state and form lattice structures. The two principal factors in determining the form of the lattice are the charge of the ions and their sizes.