The theory is that the states forfeit certain aspects of their sovereignty, but not their entire sovereignty, by entering into a federation with the other states in the United States. The specific aspects of their sovereignty that they forfeit are those powers explicitly enumerated in the Constitution. As you note, this would include the ability to enter into treaties. But the 10th Amendment (at least in theory) guarantees that they retain their sovereignty in all other areas of governance.
There is still a distinction between US territories and states, because while in practice the territories are self governing, they have no Constitutional right to self governance. The federal government grants them some degree of autonomy as a matter of pragmatism, but the federal government has the power to revoke this autonomy by a simple act of Congress. The same cannot be said of states.