All atoms want eight valence electrons in order to be stable. This is called the octet rule. Atoms form bonds in order to fulfill the octet rule.
Calcium nitrate is ionic. Ionic compounds are usually made of a metal ion and a nonmetal ion. Metals usually contain 1-3 electrons. Therefore, they tend to lose electrons from their outer orbitals. The electrons housed in the full second-outer orbital then become the atom's valence electrons. In this way, metals can fulfill the octet rule. Calcium nitrate consists of one calcium atom and two nitrates, or Ca(NO3)2. Nitrate is a polyatomic ion, which means that it consists of several bound atoms and displays an overall charge (NO3)-1 (-2 in this case, because there are 2 NO3s). A neutrally charged calcium atom has 2 valence electrons. The calcium in calcium nitrate donates it electrons to the nitrate and obtains a +2 charge. However, the -2 charge of nitrate and the +2 charge of calcium result in an overall neutrally charged compound.
On the other hand, dinitrogen tetroxide is covalent. Dinitrogen tetroxide is made of two nonmetals (nitrogen and oxygen). Nonmetals have 4-8 valence electrons. Thus, it is easier for them to share electrons when forming a chemical bond in order to fulfill the octet rule. The sharing of electrons to form a bond is the definition of a covalent bond.