Osmoregulation is the regulation of water and solutes inside cells. Cells have a membrane that is permeable to water and some solutes. Impermeable solutes utilize pumps or pores to traverse the membrane. If solutes are high on one side of a permeable membrane, water will flow towards this side. This equalizes the solute concentration on both sides of the membrane. Osmoregulation can keep balance of electrolytes stable in our body under normal circumstances (water logging and dehydration are normal). Ions are required for multiple cellular functions including enzyme function, transport, and energy production.
In the case of death by waterlogging or water intoxication, a person becomes enundated with water, which changes solute concentrations. This condition is called hyponatremia (essentially "low salt"). A person can die if the excess water is not disposed of quick enough (e.g. through urine) or extra electrolytes (e.g. ions such as sodium and potassium) are given. There is a limit at how quickly the kidney can get rid of excess water.
In the case of death by dehydration, not enough water is present. Dehydration may occur due to dysfunction of the kidneys or due to excessive loss (e.g. severe diarrhea). The water must come from the external environment since the body cannot spontaneously make water from nothing. Water can be replaced but the underlying cause of the excess water loss must be addressed as well.