Dear Student,
An atom donates and accepts electrons to attain a stable electronic configuration oxygen is a non metal and also highly electronegative. Non metals accept electrons pairs rather than donating it and so does electronegative atoms. Therefore, it is easier to gain electrons and attain full filled configuration rather than losing electrons.