Peeled potatoes turn gray in water due to oxidation, a chemical reaction between compounds in the potato and oxygen, even when submerged. This is similar to how cut apples brown.
When you peel a potato, you expose its flesh to the air. Potatoes contain an enzyme called polyphenol oxidase (PPO), also known as tyrosinase. This enzyme reacts with phenolic compounds (like tyrosine) present in the potato when exposed to oxygen. This reaction leads to the formation of melanin, a pigment that causes the gray or brownish discoloration you observe. Submerging the potatoes in water slows down, but doesn't completely stop, this oxidation process because some oxygen is still present in the water. The cold temperature of the water also helps to slow down the enzymatic reaction.
To prevent potatoes from turning gray, add a tablespoon of lemon juice or vinegar to the water. The acidity inhibits the polyphenol oxidase enzyme, preventing the discoloration.