We know the source of all energy on earth is sun. All the energy we use at some point came from the sun. The energy that a car runs on also came from the sun. A car runs on fuel such as petrol or diesel. These are fossil fuels.
Trees absorb the energy from the sun and turn it into chemical energy. This energy remains stored in the trees body. The tree that existed in the prehistoric time are now underground. The body of the trees, under pressure and heat has turned into petroleum. This petroleum is collected from underground and refined to be used as petrol or diesel.
Thus, the energy stored in fossil fuel is the energy prehistoric trees absorbed from the sun. Thus, it is clear that the energy that drives a car actually came from sun.