The few times I have run into this was one was a bad element in a electric water heater that was causing a potential difference between the water and the inside of the copper pipes connected to it.
The second time was a weak connection in the service neutral causing a difference of potential on the grounding and earth but because they had experience their water main line coming to the house getting pin holes they contacted a plumber without contacting an electrician , the plumber installed a PVC section just outside the house foundation to isolate it from the voltage to earth difference, this cause a difference of potential between the water coming in from the street and the water in the copper pipes in the house, a few months after the plastic pipe was installed we were called and we found that the utility had a bad connection at the transformer which also solved the blue water she later told us, A dielectric union at where the pipe comes into the house can also cause the same thing if there is a neutral problem and the water pipe is copper on both sides, even a problem with the primary neutral to the transformer supplying the house can cause this if there is a break in continuity of the copper water pipe, it is the only way to get a difference of potential on the water inside the pipe.
For everything else that can cause it would be a chemical reaction of a treatment chemical that maybe the water suppler is using to treat the water, but then it should be city wide for houses with copper lines or a water softener is using on well water, in Florida sulfur is a big problem and is a common element found in wells that can be very corrosive to the inside of copper pipes, while most use PVC water lines down there I have some family just outside the Orlando area that had a house with a spring fed well with copper water lines and called me to see if I had any idea how to stop it from happening, I told them to get a large green sand filter like that is used for pools and have a another tank installed ahead of it with a chlorine injector to this tank to cause the sulfur and iron to solidify into little balls that the green sand filter will remove, also told them most good water treatment company's down there should already know how to do this and should be able to fix them up, another problem is they try to sell you a brine (salt) type injector tank to soften the water, told here is it seems the soap suds is about what you would get when using most city water then opt out of the brine softener treatment, My sister called me back a week later and said she told her Culligan man what I said and he installed it, and she never had a problem since and couldn't believe the difference.
With copper water lines if you are using a brine type water softener, set the injector to the lowest setting as the salt is an alkaline and can be corrosive to the insides of copper water pipes if too much is added to the water, many softener companies will set them high as they want to sell you as much salt for them as they can, but do yourself a favor, set it low as it can go unless you have unusually hard water, but set it only as much as you need as it doesn't take much to remove the hardness of the water and you won't have to rinse your hair out forever trying to get the soap out.
