Oxygen and nitrogen actually react to form nitric oxide.
$$\ce{O2 + N2 ⇄ 2NO}$$
Oxygen react with nitrogen to produce nitrogen(II) oxide. This reaction takes place at the high temperature[about 2000°C(without catalyst) ; 1200-1300°C(with catalyst)), an overpressure and in the presence of a catalyst. In this reaction, the catalyst is can be platinum, manganese(IV) oxide.(Chemiday)
In wikipedia article of nitric oxide, it is written that:
The uncatalyzed endothermic reaction of oxygen (O2) and nitrogen (N2), which is performed at high temperature (>2000 °C) by lightning has not been developed into a practical commercial synthesis (see Birkeland–Eyde process):
$$\ce{N2 + O2 → 2 ·NO}$$
From a thermodynamic perspective, ·NO is unstable with respect to O2 and N2, although this conversion is very slow at ambient temperatures in the absence of a catalyst. Because the heat of formation of ·NO is endothermic, its synthesis from molecular nitrogen and oxygen requires elevated temperatures above 1000 °C.
Why nitrous oxide is not formed can be explained through thermodynamics. From Quora:
For any chemical reaction to take place spontaneously, we look at a factor known as free energy available for that reaction. Gibbs's Free Energy is given by the equation:
$$\ce{\Delta G= \Delta H − T\Delta S}$$ This is one of the most important equations in all of chemistry because it provides information as to whether a particular reaction is spontaneously possible or not.
The quantity $\ce{\Delta G}$ must be negative for a reaction to take place spontaneously. For the reaction $\ce{2N2 + O2 −>2N2O}$ calculating the values of change in enthalpy and temperature times change in entropy for the atmosphere, we see that this reaction can't take place.
Generally, reaction between nitrogen and oxygen produces $\ce{NO_x}$ which causes air pollution.
$\ce{NO_x}$ gases are usually produced from the reaction among nitrogen and oxygen during combustion of fuels, such as hydrocarbons, in air; especially at high temperatures, such as occur in car engines.The term $\ce{NO_x}$ is chemistry shorthand for molecules containing one nitrogen and one or more oxygen atom. It is generally not meant to include nitrous oxide ($\ce{N2O}$).