The court said the Trump administration’s maneuvers to keep her in the role without getting confirmation from the U.S. Senate didn’t follow procedures required by federal law.