Usually this is due to iron and manganese deposits. These are naturally-occurring minerals which settle in the water mains over time.
Iron and manganese are so similar that they can have the same reaction and can ruin your food, clog your pipes and even cause stains in laundry. Manganese however, oxidizes slower than iron making it more difficult to remove.
The best ways to avoid iron and manganese from well water or other treated water include water softeners, aeration, oxidizing filters and chemical oxidation.