Nitrates and nitrites are products of nitrogen gas. Nitrate which consist of a single nitrogen atom connected to 3 oxygen atoms(No3) is extremely stable or hard to remove. Nitrogen (No2) can enter your pool water from a variety of sources. It combines with oxygen to form nitrites (No2). This extra oxygen atom is not just floating on top of your pool (unless using an ozinator) so the aggressive nitrogen oxide will steal another o atom from our chlorine molecule HOCL. This makes our chlorine less effective and increases your chlorine demand. This continues as nitrites take to another oxygen atom to become nitrates (No3)
Nitrates and nitrites in pools are NOT products of nitrogen gas. I think you are mixing up pools with what goes on in soil with nitrogen-fixing bacteria that convert nitrogen gas in the atmosphere into ammonia followed by nitrifying bacteria that further convert it to nitrite and nitrate that is used as a source of nitrogen for such bacteria and by plants (interestingly the plants reduce nitrate to nitrite to ammonia for chemical reactions that incorporate nitrogen into nitrogenous organics).
The source of nitrates in pools is from the chlorine oxidation of ammonia and nitrogenous organics. While most of the nitrogen in ammonia becomes nitrogen gas when chlorine oxidizes it, around 15% becomes nitrate (the actual amount depends on relative concentrations of chlorine and ammonia).
Both phosphates and nitrates are essential nutrients required for plant growth including algae which are plants (even bacteria need phosphates and nitrates, but in lower quantities since they are smaller; by the way, black algae is technically a cyanobacteria). These are essential nutrients to all living things because the phosphorous is used in the core chemical energy system ADP/ATP and in the phosphate deoxyribose backbone of both DNA and RNA while nitrogen is found in many organic compounds including amino acids (and therefore proteins), DNA, RNA and many other compounds.
However, just because phosphates and nitrates are essential nutrients for algae does NOT mean that algae will always grow faster than chlorine can kill it. There is a limit to the rate at which algae can grow regardless of the phosphate or nitrate level. Algae is also limited in its growth by the amount of sunlight and by temperature. So if one has a sufficiently high active chlorine (hypochlorous acid) level, then algae will be killed faster than it can grow regardless of algae nutrient (phosphate and nitrate) level.
The problem is that you were probably never told how to figure out the active chlorine (hypochlorous acid) level that is required to kill algae faster than it can grow. The Free Chlorine (FC) to Cyanuric Acid (CYA) ratio determines that active chlorine level. So long as this FC/CYA ratio is 7.5% or larger in non-SWG pools, then green and black algae will be killed faster than they can grow. This assumes, of course, that you don't already have an algae bloom. If you do, then it takes higher levels of chlorine to kill the algae because 1) the chlorine gets consumed quickly oxidizing the algae and 2) the algae in a bloom is clumped so the algae inside the clumps can still grow so it takes higher levels of chlorine to get inside those clumps more quickly to kill the algae.
Think of phosphates and nitrates being fuel for a fire, so like wood in a fireplace. If you try to start a flame (algae growth) but are dousing the wood with water (chlorine) fast enough to put out the flame, then it doesn't matter how much wood there is in the fireplace. A fire will simply not get started because you are putting it out faster. The amount of fuel is irrelevant. You just have to remember that the FC number by itself does NOT represent the strength of the chlorine. It only represents the capacity or reservoir of chlorine. The activity of the chlorine is proportional to the FC/CYA ratio. So if you have higher CYA, then you need a higher FC level to maintain the same chlorine activity. If you don't do that, then algae can grow faster than chlorine can kill it.