Poop is brown primarily because of a chemical called stercobilin, which is a product formed during the breakdown of old red blood cells. The process begins when red blood cells break down, releasing hemoglobin, which then degrades into bilirubin. Bilirubin is processed by the liver into bile, which enters the digestive tract. In the intestines, bacteria convert bilirubin into stercobilin, which has a brown color and gives poop its characteristic brown hue.
Bile itself is yellow-green, but after it mixes with bilirubin and undergoes chemical changes through digestion, the resulting stercobilin is brown. This explains why poop is almost always some shade of brown, regardless of the color of the food eaten.
In summary, the brown color of poop is mainly due to stercobilin derived from bilirubin, which comes from the natural breakdown of red blood cells and the body's digestion process.