This week, the president suffered a string of defeats that exposed the real limits of his power at home and abroad.