The court's decisions cemented Mr. Trump's authority over vast swathes of the government, while delivering significant setbacks to his agenda in other areas.