Why does the check engine light come on a 2002 ford explorer after you have replaced the erg?

Assuming you mean the egr valve, I would make sure that you have the check engine codes cleared. In addition, are you sure that it was truly the egr valve, and not the DPFE sensor monitoring the valve?