Hello Student,
Becausesilverhas an overwhelming affinity forhalideions. Thesilverion, acting as a Lewis acid, result is a nucleophilic substitution reaction in whichnitriteis the nucleophile. Nitriteneedssilverfor this because it's not all that good a nucleophile.
On treating ethanolic solution of nitroalkane with silver nitrite (Ag−O−N=O), nitroalkane is formed because since the bond between Ag−O covalent, the lone pair on nitrogen acts as an attacking site for nucleophilic substitution.
But on the other hand if haloalkane is treated with potassium nitrite, alkyl nitrite is formed as major product because since the bond between K−Ois ionic in nature, the negative charge on oxygen serves as an attacking site.
Regards
IHE