Continental deserts are found in the centers of continents far from water sources. The winds which blow across these deserts may have left water sources carrying much moisture, but as they cross mountain ranges and high plateaux, the rain shadowing process occurs repeatedly. By the time the winds reach the centers of the continents, much of their moisture has been lost. The Gobi desert in central Asia was formed this way. You might be surprised by the presence of deserts near the ocean - after all, the air there ought to be pretty moist.
Coastal deserts form where there is a cold ocean current offshore.
Moist air flows over the cold current and cools, lowering its moisture-carrying capacity. What moisture is left often forms coastal fogs in these areas. Much of Baja California is a coastal desert formed because of the cold California Current, while the Namib desert in southern Africa is due to the Benguela Current. Wind moves sand grains by saltation and rolling, just like in rivers. Over time, these sand drifts get larger and coalesce to form a full-fledged dune.