A 'stroke' is the movement of the piston from 'top dead center' (TDC) to 'bottom dead center' (BDC), or the other way round, from BDC to TDC. A 4-stroke engine has four strokes. They are intake, compression, power, and exhaust.
A 4-stroke gasoline engine uses internal combustion, meaning that the heat that causes the air in the cylinder to expand is generated inside the cylinder. By comparison, a steam engine produces its heat in a furnace and boiler outside the engine cylinder so it is an external combustion engine.
The four strokes must include the five key events common to all internal combustion engines - Intake, Compression, Ignition, Power, & Exhaust.
Intake: Taking in air-fuel mixture
The intake stroke starts with the exhaust valve closed, the inlet valve opening, and the piston at its highest point, top dead center. As it moves down, it increases the volume above the top of the piston. This makes pressure inside the cylinder lower than the pressure outside. This higher outside air pressure forces the air-fuel mixture into the cylinder. The piston reaches bottom dead center, the inlet valve closes, and the intake stroke ends.
Compression: Squeezing the air-fuel mixture into a smaller volume
Both intake and exhaust valves stay closed as the piston leaves bottom dead center. The piston moves up, squeezing the air-fuel mixture into a smaller and smaller volume, which compresses it. That causes the air/fuel charges temperature to rise, and that makes ignition easier and combustion (burning of fuel) more complete.
Ignition and Power: Burning the air-fuel mixture and forcing the piston down
Just before the piston reaches top dead center, the next key event occurs - Ignition. The air-fuel mixture explodes and as it expands it pushes the piston down the cylinder. This is the Power stroke that drives the engine.
Exhaust: Getting rid of the burnt gases
The piston now moves from bottom dead center to top dead center. The exhaust valve opens, and the piston pushes out the leftover gases.
Remember, the intake valve is only open during the intake stroke, and the exhaust valve is only open during the exhaust stroke. Both are closed during the compression and power stokes.