There are three main fossil fuels used by human civilization.
Fossil Fuels are formed from dead plant and animal matter, after exposure to a fair amount of pressure over a large period of time.
After the living stuff died, it got buried under layers of mud, sand, and eventually rock. Time passed, and it got buried deeper and deeper, until it started running into geothermal energy, which heated it up.
This heat would speed up the process. The type of fossil fuel obtained depended on what type of organic matter you started with. Crude Oil and Natural Gas would be made from aquatic plants and animals that had been trapped under silt at the bottom of an ocean or lake.
The heat and pressure, aided by some bacteria which would help decompose the organic matter, broke the materials down to liquid hydrocarbons. If it was hot enough, the process would continue, breaking it down to methane, which is the primary component of natural gas.
The crude oil and the natural gas would then start seeping upwards, until they hit formations of denser rock, called caprocks, under which they would remain stuck. That is, until we drill down beneath these caprocks to get to em.
Coal, on the other hand, was formed from the remains of plants. Back in the day there were a bunch of swamps. Dead plants would sink to the bottom of the swamps and become buried.
After that it was the same story. Pressure, time, heat, bacteria. The older the coal deposit is, generally, the better quality it is. In fact, some of the lower quality coal deposits are new enough that you can still see the grain on the wood that it was originally made out of.
Basically, as coal ages, and becomes better burning, its carbon content increases, while its concentration of various other stuff found in plants decreases.
Generally there's about a 10 to 1 ratio of plants stuck in the ground to coal dug out later, with regards to volume.
Often the swamps would later be covered over with sea water. This is a bad thing, as sea water contains a fair amount of sulphur, which would get into the coal, and be released into the atmosphere when burned. This is the main cause of acid rain.
Of course, we're now working on better ways of getting rid of the sulphur in coal, mostly by filtering the exhaust before releasing it into the atmosphere.
What do we do with it once we have it out of the ground?
Coal: Burn it! Coal is one of the most plentiful fuels, and it is used mainly for in the generation of electricity. Over half of the electricity produced in North America is from a coal power plant.
Petroleum: All sorts of stuff. And Burn it. Crude Oil is used in the production of all sorts of stuff, from plastics, pharmaceutical products, Kevlar, Teflon, computers, televisions, skin cream, portable CD players, oh yeah and this stuff called gasoline too...
Hey! Aren't we going to run out of this stuff?!
Hell yeah. It's a non renewable resource. Well, it is renewable, but it does so as such a slow rate that we'll all be dead by the time we get some more. Someday we will all be crude oil and diamonds.
Well what are we going to do about it?!
Pray to hell that someone figures out cold fusion? Get used to using solar power, a few more hydro-electric dams, and nuclear power plants. Either that or rewind back to before the industrial revolution.
That sucks dude.
Tell me about it. Probably for the best, since burning all of these is speeding up global warming. If we were able to keep it up, we'd probably end up killing ourselves like the idiots we are.
Sources:
www.fe.doe.gov/education/
www.bydesign.com/fossilfuels/links/html/fossil_fuel.html
My own muddled memory