As nitrogen and oxygen atoms are small and highly electronegative with no vacant d-orbitals available for bonding multiple bonds are formed between oxygen-oxygen and nitrogen-nitrogen atoms.
N ≡ N O = O
As the size of P and S atoms is large so multiple bonds are not strong enough, also catenation is possible due to vacant d-orbitals.