The same way the surface material formed into sedimentary rock.
Do the math, sedimentation as little as 1 inch every 1,000 years is over 6 miles deep after 400 million years.
Oil is found in sedimentary basins that were formed under ancient oceans or lakes. You need to understand that they are only found if rock formation that were formed from sedimentation sources.
So is the earth 6 miles thicker than it was 400 million years ago? Where did all that new mass come from?