You need oceans and geologic activity for life, so there would always be oil. Coal is from trees dying and piling up faster than they rot…so vascular plants need to develop much earlier than fungi.
1) plankton or something plankton-like develops and generates a lot of biomass, and
2) its remains aren't dispersed or digested by other organisms, and
3) it has time to turn into petroleum, and
4) all of this happens far enough ahead of intelligent life so that it's ready when they need it, and in sufficient quantity to bother.
You could build a "Drake equation" model about how likely this is, and maybe it's pretty likely, but it's not inevitable.
For life like our life that is. There's so many assumptions here.