This is because the electron configuration of Nitrogen is 2.5 while that of oxygen is 2.6. This is putting into perspective that the stable configuration for this period of elements is 2.8. Therefore Nitrogen would require 3 electron to reach stable configuration (2.8) while oxygen requires 2. This means that in sharing of electrons in covalent bonds, nitrogen will form three(3) bonds while oxygen will form two (2).