The president’s remarks were a surprisingly public acknowledgment that he had campaigned for his freedom as much as for the White House itself.