Although there are many remaining mysteries about the formations of sand dunes, wind and sand are essential.
The wind transfers the sand in a variety of ways, saltation (sand bouncing along the beach) being the most common with 95% of sand being moved this way, and volumes.
Depending on those two factors, different formations appear.
And that’s an extremely overly simplified version of the process.
There’s so much more involved!