That's why you'll still fail a state emissions test if you just shut the light off and go. Their reader wont see a clean emissions reading. You have to drive the car for a while after you clear a code to truly reset everything.
To simplify- what the state emissions test is looking for is that the car has completed all the necessary self-tests, has passed them all and set the code for that. If the trouble codes have been cleared, that will show up as having not completed all the self-tests.
Another use for the code reader is to verify the car has passed all the self-tests needed before going to the emissions testing station (if you have one).
There can also be "pending" codes. For example, if you leave the gas cap off and lose it, you won't get the yellow light until the 3rd trip (in my 2001). But if you were to read codes before seeing the light there would be a 'pending' code indicating something could be wrong.