Primarily the filtration media acts as a barrier so fine particles can pass through the filter vessel but will hold back the bigger particles within the filter system.
The roughness of the outside edge of the filter sand traps fine particles and stops them flowing through the filter.
The water filter can then be backwashed removing the particles from the sand and flushing it down to drain. Once the sand is clean the water filter would then return back to its service position giving clean filtered water.