You can see in the figure that a device called a piston replaces the potato in the potato cannon. The piston is connected to the crank shaft by a connecting rod. As the crankshaft revolves, it has the effect of "resetting the cannon." Here's what happens as the engine goes through its cycle:
The piston starts at the top, the intake valve opens, and the piston moves down to let the engine take in a cylinder-full of air and gasoline. This is the intake stroke. Only the tiniest drop of gasoline needs to be mixed into the air for this to work. (Part 1 of the figure)
Then the piston moves back up to compress this fuel/air mixture. Compression makes the explosion more powerful. (Part 2 of the figure)
When the piston reaches the top of its stroke, the spark plug emits a spark to ignite the gasoline. The gasoline charge in the cylinder explodes, driving the piston down. (Part 3 of the figure)
Once the piston hits the bottom of its stroke, the exhaust valve opens and the exhaust leaves the cylinder to go out the tail pipe. (Part 4 of the figure)
Now the engine is ready for the next cycle, so it intakes another charge of air and gas.
Notice that the motion that comes out of an internal combustion engine is rotational, while the motion produced by a potato cannon is linear (straight line). In an engine the linear motion of the pistons is converted into rotational motion by the crank shaft.
The rotational motion is nice because we plan to turn (rotate) the car's wheels with it anyway.
Now let's look at all the parts that work together to make this happen.