Ammonia (NH3) is the waste product excreted by fish and created by decaying plant life within the pond and it is toxic to fish. When passed through your pond filter along with the oxygenated water from the pond they flow through biological media which over a period of time has developed the beneficial bacteria which converts the ammonia into nitrites
Nitrites (NO2) are also toxic to fish, but other beneficial bacteria in the filter will convert these into less harmful nitrates.
Nitrates (NO3) are used by pond plants (including algae) as food, these nitrates will naturally convert into nitrogen.
Nitrogen is the gas that makes up 80% of the air that we breath and that our pond needs to contain life.
As well as beneficial bacteria within the ponds filter there are many single-cell organisms and various larger creatures such as daphnia that also feed on the waste products traveling through the filter these also help to remove fine particles such as algae from our pond water, but these methods of filtration cannot remove everything and so we must perform regular water changes and filter maintenance to prevent any build up of waste and minerals.