Both wind action and water action have important parts in this process and constantly change the boundary between land and water. Coastal erosion takes land away forever from one area to deposit it someplace else. The beach is constantly pounded by waves which eventually break fragments of ground and rock into sand. How hard a beach is hit by waves depends on lunar tides and differences in water density. There is no continuous groundcover on the beach, so sand dunes form easily.
Wind blows sand particles from side to side.
People sometimes build fences to keep sand from shifting so much. Eventually, the sand is blown away and water takes its' place. The land is gone. These waves take the sand in front of the seawall and deposit it far away from land. The water in front of the seawall gets deeper and makes for bigger waves next to the shoreline, so you always have to build bigger seawalls.