Oil and Gas generated from deposits of hydrocarbons and deposits of hydrocarbons are known generated from the fossil of animal and plants. The most common theory is that sediment and animal / plant groups are be transported to sea by river and mixed with plankton before numerous amounts of silt buried underneath. The organic material had been decay and disassembled through the extremely high pressure and heat over millions of years and it is a hydrocarbon decomposition product as we speak today.
Hydrocarbon decomposition does not always stored in huge cavern had oil or Gas but containing actually filled in many rock contains lots pores like a water sponge soaked. This rock help so that Gas climb up and Oil Gas flows down to imperviousness rock layer or shale. Hydrocarbons trapped by the cap rock are accumulated in the border naturally made. We usually call it Well and those accumulated well drill by the drillship.