And how was coal created when there were no plants on land, before there were land plants?
Mind the coal gap
The wide, shallow seas of the Carboniferous Period provided ideal conditions for coal formation, although coal is known from most geological periods. The exception is the coal gap in the Permian–Triassic extinction event, where coal is rare. Coal is known from Precambrian strata, which predate land plants — this coal is presumed to have originated from residues of algae.
Formation of coal | Wikipedia
Why is so much coal mined on or very close to the surface of our planet?