Slip and stick
The friction between your shoes and the floor is quite non-linear. As you put your foot down, your shoe comes under elastic strain as your foot moves forward but friction holds the bottom in place. This is the stick phase. As your foot moves forward, the strain becomes too big, and the friction between floor and shoe can't overcome it anymore.
The bottom of the shoe starts to move. The dynamic friction now is lower than the static friction before, which means the acceleration is rather large. However, the strain also dissipates quickly as the shoe flexes back to its original form. This slip phase is therefore also time-limited.
So, when you hear a high-pitched squeak, you're hearing your shoe stick and slip several thousand times per second, moving micrometers at a time.
Water definitely affects the static and dynamic friction, so that explains why it can matter. But note that there's no simple rule about the exact change in friction, and therefore adding water may also prevent squeaky noises in other situations (when it acts as a lubricant)