States have a general police power, meaning that they can pass laws about whatever they want unless there's a specific reason they can't. A state does not have to give special justification for why something is in the realm of stuff they can regulate; someone challenging it has to say what specific section of the Constitution it violates.
For a time, the Due Process clause of the US Constitution was considered to imply freedom of contract. This time ended in the 1930s. The doctrine of a constitutionally protected freedom of contract is pretty much completely dead. A state can't abridge the freedom of contract for no reason, but that's because just about any law needs some reason to be allowed. The level of review is that the law is rationally related to a legitimate state interest; this is not a very demanding level of review. Source
State bar associations are given power by laws making it illegal to practice law without being a member of the bar and requiring licensed lawyers to comply with bar rules. State bars that control admission to practice are generally government agencies (specifically, agencies of the court system). When the state bar is not a government agency, attorney discipline and licensing is handled by a government agency (lawyers might have to join the bar, but the bar has to accept licensed lawyers as members; the bar's power in these cases is limited to recommendations to the courts).