I fly fish high mountain streams with foam. It's caused by decaying organic matter. The matter causes a disruption to the skin or surface of the water creating air bubbles. In the fall, when the aquatic grasses start to die and decay, it's most prevalent. It has a light tan hue to it.
If you find very white foam, it is possible it comes from a man made contaminate.