Difference between valency of nitrogen and phosphorus though both have same valence electrons
At your current stage, it's probably easiest to consider the octet rule which applies to nitrogen and the expanded octet rule which applies to phosphorus.

If nitrogen and phosphorus made five bonds, they would have 10 electrons total. This is inconsistent with the octet rule but valid under expanded octet.

In reality, the situation is governed by the fact that you need more orbitals to accommodate the extra electrons for the two extra bonds. Unfortunately, no orbitals of comparable energy to the $2s$ and $2p$ are available, so the stabilization of the electrons in the putative molecular orbitals would be poor in nitrogen. With phosphorus, you might more readily access the $4s$ and $3d$ orbitals which are closer in energy to the $3s$ and $3p$ orbitals.