Carbon has 4 electrons in its outer shell, a pair in the 2s and two unpaired electrons in the 2p. For covalent bonds to form, each atom must donate one unpaired electron. Carbon makes four bonds because it can unpair its electrons in the 2s and promote one into the empty space in the 2p for a small energy cost. This cost is then recovered by sharing these 4 unpaired electrons with those from other atoms. The carbon has now filled its outer shell and is satisfied.
Nitrogen has one pair of electrons in the 2s but 3 unpaireded electrons in the 2p. There is no space in the 2p orbitals to unpair the 2s electrons and promote one into the 2p, meaning the three unpaired electrons form 3 covalent bonds. The Nitrogen outer shell is then full.