States even sometimes agree to give away one of the most essential elements of sovereignty, the decision whether or not to take their citizens into war. That's what alliances are, the promise to automatically go to war if any member of the alliance is threatened. States can decide at the last minute whether or not to honor that commitment as Britain and France decided not to honor their alliance commitment to Czechoslovakia when Hitler invaded it in 1938. However, history tells us that alliance partners usually do honor their commitment. I am absolutely certain that had the USSR invaded Germany during the Cold War, the US would have immediately honored its NATO commitment.
States take their agreements seriously.
That is why the U.S. has refused to sign several treaties. They do not want to sign an agreement that they know they will have to violate because it does great harm to be considered an outlaw state. That doesn't mean that states don't violate treaties once signed. Saddam's prevention of international inspection of his nuclear program is a clear violation of the NPT that Iraq signed. However, states abide by their agreements most of the time and reserve violations only for the most important cases.