Oil is fluid, so it will not necessarily stay where it is formed, but it will flow through the rocks until it is stopped by impermeable rocks, like granite.
So there is nothing surprising in finding oil elsewhere than where it has formed.
Some hydrocarbons can form in the absence of life, e.g. by Fischer-Tropsch synthesis from syngas, catalyzed by some minerals, where syngas can form in volcanic gases or in hydrothermal vents. However that is likely to have been a negligible contribution to the oil reserves of the Earth and most or all oil ever found has a chemical composition that has clear indications of being produced by the decay of organic matter from living beings.