The ground state electronic configuration of oxygen is which indicates six electrons in its valence shell. Oxygen needs eight electrons in its valence shell to complete its octet and become stable.
The two electrons required are shared with oxygen by an electron donor atom which leads to the formation of two bonds. Two oxygen atoms can share their valence electrons which leads to the formation of a double bond between the two atoms.
Once the octet of Oxygen is complete, it does not have any more vacant orbitals left. Thus, it cannot accommodate any more electrons and form any more bonds.
Oxygen can form only two bonds because it requires two electrons to complete its octet after which it will not have any more vacant orbitals left to accept more electrons and form more bonds.