The president’s comments on immigrants from El Salvador, Haiti and other nations surprised lawmakers.