Sharing of 4 electrons between two atoms results in two double bonds. This can be see in the case of oxygen molecule (O2)
Atomic number of O = 8
Electron configuration of O = 1s²2s²2p⁴
Valence electron configuration: 2s²2p⁴
When 2 O atoms combine they share 4 electrons to form 2 double bonds. In addition, there are two lone pairs on each O atom.
Structural formula: O=O