The process is the sedimentation and lithification of ancient plant remains through compaction and removal of water via overburden pressure.
Start with a lush tropical swamp. Vegetation grows and dies, falling in the water but not decomposing. Millions of years of this occurs. Thickness of dead plant material grows and grows. Then, over millions of more years, this organic sediment is covered by a sea that comes and goes, depending on plate movement and crustal uplifting and rifting, depositing vast amounts of sand, mud, and clays over them. The pressure of the sediments above squeeze the water out of the organic sediment below, and in time these organic sediments become lithified (turned into rock).