The light may come on immediately upon detection of a problem, or it might take some time depending on the severity and nature of the fault. Some problems might cause the light to flash, indicating a more serious issue that requires immediate attention.
To know *why* the check engine light is on, you'll need to have the codes read using an OBD-II scanner. Auto parts stores often offer this service for free. The codes will give a more precise indication of the problem.