why do we get both fossils and fossil fuels primarily in the sedimentary rocks

The sedimentary rocks are hard and doesnot let any fluid to flow away. Hence we get fossil fuels in this rocks.