This is a built-in function in the OBDII standard. The ECU regularly performs a set of "readiness tests" to monitor the condition of various major components. When the car is scanned, the first thing that comes up is the status of these tests, "complete" or "not complete". Any time a full reset is performed by disconnecting the battery, or a "clear codes" command is sent from a scanner, the readiness test status is reset to "not complete" and the tests have to be performed again. This was done on purpose so it wouldn't be possible to mask a problem pre-inspection just by doing a reset, unfortunately you've discovered it the hard way. If your state does inspection via OBDII scan, you will fail if the CEL is on, any codes are present, or the readiness tests are not complete.
There is no way to "fix" a "not-complete" status other than to drive the car until the tests complete themselves. It should take a couple of days of normal driving.
One other thing that has been known to interfere with the readiness tests is installing an electrical "CEL fix" for a catless downpipe. Although the fix may eliminate the constant CEL, some have been known to prevent the tests from completing and will cause an inspection failure if it requires an OBDII scan.