It’s a little more complicated than that. Mars could hold nitrogen. It just didn’t get a significant amount. It can hold oxygen, but the oxygen hooked up with iron, forming a red compound we refer to on Earth as ‘rust’. Hence, Mars is known as the Red Planet.
What Mars can’t hold is hydrogen. It should lose half or more of atmospheric oxygen in roughly 40 million years. If one assumes 4.5 billion years, that’s 112 times to lose half the hydrogen. Thus any hydrogen remaining is buried in ice or subsurface water.
H2O gets broken up by ultraviolet light quickly without lots of ozone in the atmosphere. Gravity on Earth keeps the hydrogen around long enough to recombine with oxygen. Pre-life Earth had no free oxygen. There is no convincing evidence that Mars ever had or has life to date (2022).
Flipside, human engineering could easily bring life to Mars, by adding atmosphere deep enough to hold heat. 1% of the atmosphere of Venus, minus excess sulfur, would work.
Separating the Martian rust into iron and oxygen using standard techniques would help, and then hauling ammonia from any available source to make amino acids/proteins. Glass or clear plastic will block UV. But these changes require human or machine intervention, and won’t happen spontaneously. It takes a Creator to terrform a planet.