for flying smaller cessna type planes, flap retraction is on a checklist completed after the plane has cleared the active runway. This is simply to expedite clearing of the runway and reduce the chance you will get distracted and somehow mess up. Its probably similar reasoning for larger commercial aircraft.