How do oases form in the middle of the desert?
Oasis are places where aquifers are connected to the surface. The source of the water in the aquifer however can be hundreds of miles away in areas that do get significant rainfall. 

The trick is geologic strat have different properties; some allow water to flow easily, others are very water tight, a water accessible layer covered by a water proof layer creates a aquifer. Faults or erosion can breach this water seal allowing to water to the surface, as can human wells. Recharge areas are places at higher elevation where water can enter the aquifer and flow downhill, they can be hundreds of miles away and are often in the mountains which often get much higher rainfall.  A picture is worth a thousand words.