basically both valves open earlier and shut later than BDC and TDC.
the way bob tait explains it doesn't really sound right but if you can accept that the gas has a "mass" and therefore "inertia" keeps it exiting/entering the cylinder after the piston has reached TDC/BDC
hope that kinda helps