The Middle Eastern oil-rich countries are those primarily on the Arabian Plate . This piece of land was under water for most of its history. During that period, billions upon billions of marine creatures, from algae and bacteria up to whatever else was swimming around, sunk to the sea bottom and formed layers that are literally miles deep.
Those layers compressed as more and more layers formed on top of them. That compression turned them into oil. Interestingly, most oil is captured on the seabed by thick layers of salt. When the land rises due to tectonic activity, it becomes easier to exploit, though there are drilling operations in various seas.
With very few exceptions, oil is found under what is or what was seabed. Other seabeds and former seabeds are explored for oil and most of them have been brought into production. Some of the areas have already been exhausted. More newly discovered oil areas -- like that off the coast of Brazil -- are in very deep water.
As for the "why," it's coincidence or an accident of history.