A series of setbacks for Trump with Republicans in Congress and in the courts have plagued a president already struggling in polls.