We all have studied surface tension in science. Surface tension is present in liquids, which allow molecules to be in constant motion. These molecules collide with each other but give enough space to molecules to hold on to each other. This is how liquids flow, and this is the property by which ants flow in water.
The molecules which hold each by attractive forces do not remain same at all points. They are constant or uniform at the center and at the bottom the molecules are unbalanced. The strong forces that molecules exert on each other are responsible for the inward movement of liquid. It is noticed that there is invisible elastic skin which causes the liquid to contract and which also decreases the surface tension. This phenomenon of constructiveness called surface tension.
So, the reason why ants float in water because the weight of ant is so light that it does not overcome surface tension which causes the contracting forces to break and causes the ant to float in water.