Nevertheless, some plants have symbionts that are various kinds of bacteria and which can take nitrogen from the air. The most important of these plants are the legumes, i.e. beans, peas, lentils and all their close relatives.
The ancestor of the chloroplasts, which are the parts of the plant cells that capture the solar energy, were free-living blue-green algae a.k.a. cyanobacteria, which had been able to take nitrogen from the atmosphere for billions of years.
However during the integration of the chloroplasts into the nucleate cells of the plants, when they have lost their ability to live independently, the chloroplasts have been simplified and among the lost features was the ability to take nitrogen from air. Thus the plants do not have this ability and they have remained dependent for nitrogen on bacteria that either live independently or in symbiosis with plants.
Before humans have started to convert nitrogen from the air into ammonia, for fertilizers and other applications, all organic nitrogen came ultimately also from the air, through the blue-green algae or through other kinds of bacteria.
The nitrogen content of natural rocks is negligible. All the rocks with nitrogen, e.g. saltpeter, come from the decomposition of bodies or excretions of living beings.
In all planets that are not cold enough for ammonia to become a liquid or an ice, the nitrogen is almost entirely in the atmosphere.