WASHINGTON — The Trump administration may be headed for trouble in the Supreme Court. It has twice switched sides in important Supreme Court cases, on workers’ rights and voting rolls, abandoning the positions of the previous administration for ones favored by conservatives.

Such legal U-turns can try the justices’ patience. In the Obama years, some of the testiest exchanges at oral arguments involved changes in legal positions that seemed prompted by politics. Mr. Trump’s lawyers may now also have some explaining to do.

The decisions to change course cannot have been made lightly, as lawyers in the solicitor general’s office, the elite unit of the Justice Department that represents the federal government in the Supreme Court, know that switching sides comes at a cost to the office’s prized reputation for continuity, credibility and independence.

Both cases involved the interpretation of federal statutes. The Obama administration read them to mean one thing. The Trump administration said they meant the opposite.