Congress once tried to enforce this, with the Tenure of Office act of 1867 (to try to keep President Andrew Johnson from replacing some of Lincoln’s anti-slavery appointees with more moderate-slavery ones). Johnson refused to follow this; it was one of the charges against him in his impeachment, but he was not convicted.
Twenty years later, this act was repealed by Congress. Eventually, a similar law relating to Postmasters went all the way to the Supreme Court. The Court found that law unconstitutional, an in an aside, said that the Tenure of Office act was invalid.