An oxygen atom can form two covalent bonds. An atom's number of valence electrons dictates how many bonds the atom can form. Since an oxygen atom has six valence electrons and wants eight, it uses two of its six valance electrons for bonding. The remaining four exist as lone pairs.
Even though oxygen has six valence electrons, it is unable to form six covalent bonds. If oxygen formed six covalent bonds, then it would share a total of 12 electrons. Oxygen, like most other atoms, is most stable when it shares eight electrons only. Since oxygen needs two more electrons to reach the eight it needs, it only forms two bonds.