Obscured asymptotic giant branch stars in the Magellanic Clouds - II. Near-infrared and mid-infrared counterparts