There are a variety of ways in which "fossil fuels" (coal and any long hydrocarbons, basically) could be made, but if you're asking how the oil and gas deposits of the world actually were made millions of years ago, that is not currently known with any degree of certainty. A popular hypothesis is that they are the remains of what were once living plants, animals, protists, bacteria, etc. There is no actual evidence of this being the case. It is, however, a completely plausible idea, and there is currently no better hypothesis that provides more insight. We know that biological matter can become the required material, and so of course it must at some frequency, but there's no way to know whether this process actually accounts for a given percentage (like 100%) of the world's coal and hydrocarbon reserves.
Of course the term "fossil fuel" presupposes this is how they came to be, so if another hypothesis is found to be true instead, the term will be obsolete. Aside from the incidental lack of conclusive evidence, there's no real weakness in the biogenic hypothesis.