The president had blamed Ms. Nielsen for the rise in migrants who illegally entered the United States even though she supported his hard-line immigration policies.