Sand dunes are formed by the action of wind. Erosion of rocks by chemical and physical processes generates sand particles. These particles are blown away by wind. Depending on the strength of the wind and size and type of the particles, they are blown to different distances. Heavier particles are blown to small distances, while lighter particles tend to stay afloat for longer and hence travel greater distances. However, with time, all the airborne particles fall down to the ground and get deposited. This deposition forms the sand dunes. These physical structures vary in shape and size depending on the wind strength, particle size, etc.
Sand dunes may also be formed by water, though to a much lesser extent than those formed by wind action.
Hope this helps.