I was curious about that too, so checked some dates. The Carboniferous started around 350 million years ago, and ended 50 million years later, so there would have been 50-100 million years for the coal to have formed from the vegetation.
I read a while back where all the periods overlap and things that supposed to have happened in one era happened in another.