To paint a better picture in your head, the internal combustion engine starts with the camshaft opening the intake valve, allowing air and fuel commanded by the ECM to the combustion chamber. All valves then close for the piston to compress the air-fuel mixture. Once the piston reaches the top, the ECM commands spark for combustion to occur pushing that piston down, creating power. Finally, the camshaft opens the exhaust valves and the pistons come back up to let the gases out of the exhaust manifold. With all of this in sync, this is how combustion occurs.