It absorbs organic material that lowers the water's redox. It does not absorb ammonia, nitrite, or nitrate directly. The organic material would eventually break down into more harmful chemicals like nitrite, nitrate, etc., if left free in the water.
The trouble is that carbon also absorbs trace elements that are beneficial to fish and plants.
Many of the synthetic materials that are available are superior to carbon. I stopped using carbon long ago and switched to Seachem's Purigen. It is pure white and turns dark brown when it is exhausted, so it's easy to tell when it needs replaced. It lasts a LONG time, at least 5 times longer than carbon. I have found that when it's first put in a tank, it polishes the water so well it looks like there isn't even any water in the tank and the fish are floating. It doesn't absorb trace elements. And, while it is on the slightly expensive side, it can be regenerated at home using bleach, a dechlorinator, and carbonate buffer. I recently tried it and found it worked really well. I tried it on some I had in my canister that was almost black. When I was done it was pure white again. I tested it in a glass of water with a chlorine test strip when I was done and there wasn't a trace of chlorine.
Again, just like carbon, it doesn't remove nitrate, nitrite, or ammonia directly, but rather absorbs dissolved organics that would otherwise break down into these types of toxic chemicals.