Fortunately, all fluid counts. The recommendation was originally for fluid, not specifically plain water. Doctors simply started referring to water because it was easier than explaining what counted as fluids. It didn't help

The body recognizes the water in coffee, juice, flavored drinks, etc. Some beverages do contain caffeine or sodium, but it's been shown to have nearly negligible effect on the amount of fluid we consume or lose, so the fluid still counts. Most soda contains very little sodium, about 20 or 30mg.
To say that flavored water doesn't count would be the same as saying the water we drink with a meal doesn't count, since it all gets mixed up once we swallow it. The flavor doesn't change the water, it's simply something else in your glass in addition to the water.
Also, most foods contain a fair amount of fluid, and it counts too!
According to the Institute of Medicine, 80% of our fluid needs usually comes from water and other beverages, and the remaining 20% usually comes from food. Your percentage may vary, of course. Fruits and vegetables can be as much as 80% water or more. Even bread contains
some water.