They don't drop it directly onto flames; rather, firefighters anticipate where the fire might spread, and they drop the retardant ahead of the flames. It doesn't actually extinguish fires, but it does make it harder for trees and leaves to combust and buys firefighters time to clear out brush and vegetation that could cause a fire to spread.
There is, though, an environmental risk associated with retardant, according to AccuWeather. Fertilizer is one component of many retardants because of how it sticks to vegetation to repel flames. It can kill fish and make a waterway toxic with ammonia and phosphate if dropped over or near an aquatic area.
SEE ALSO: These aircraft are on the front lines of the fight against California wildfires