I asked my friends about this but they were more interested in investigating sandcastles than trying to answer the question.
It most certainly is something to do with the water. Water wet’s most things.There are some things that water doesn’t wet. Things which are wetted by water are called hydrophilic while those that are not wetted by water are called hydrophobic.
Sand is hydrophilic so water can act as a sort of glue between sand particles, holding them together. It’s not a very strong ‘glue’ but it is enough to stop the sand particles falling apart in the sand castle. For more on this look at this previous question. Some scientist have done some research and found that you need between 1% of the mixture to be water to keep the sand together. T
There is, however, the small problem of the type of sand. There are lots of different types of sand. Sand comes from broken rocks and animal skeletons. Different rocks and skeletons change the colour of the sand. The most common sand is from quartz rock (SiO2)
Black sand comes from eroded volcanic material such as lava, basalt rocks, and other coloured rocks and minerals, white sand was once the skeleton of animals, shells or coral reefs.
Sand is formed by the action of the sea on the rocks, constantly moving the rocks and breaking them. It is thought that the flatter the beach the smaller the particles of sand are. For steep beaches the sand particles are larger. It is something to do with wave motion.