"Pairing" electrons doesn't by itself bring an energetic advantage. (And just in case of doubt: the magnetic interaction between two electrons is very weak). So since electrons repel another due to their charge, a lone carbon atom (something rare) puts two unpaired electrons on 2px and 2py because they're farther apart there (an other reason exists, Hundt's rule, yes), and a lone nitrogen atom puts three unpaired electrons on 2px, 2py and 2pz.
The whole trick of paired electrons is when this permits to put more (=two each) electrons on an orbital of lower energy. Take H2 as an example: at small distance, what were two 1s orbital become one bonding and one antibonding orbitals, which would be energy-neutral or even unfavourable, BUT the two possible spins permit both electrons to occupy the bonding orbital, resulting in a net gain.
Sometimes orbitals are favourable enough that two electrons there have a lower energy (2p in a lone carbon atom), sometimes the energies are close enough that repulsion puts the electrons apart (2px and 2py have the same energy in a lone carbon atom), and sometimes it depends (transition elements).
This holds for molecular orbitals too. O2 has two lone electrons on two molecular orbitals of identical energy.