By tuning the laser very precisely to the frequency of one particular sort of bond (such as that with a heavy carbon atom at one end), a molecule containing that bond can be shaken up.
Light ones are more easily deflected than heavy ones, so the two forms of carbon get separated, and when each atom reaches a detector at its expected arrival spot, it can be counted.