Marriage cannot be treated like contract law because the implications of marriage are far reaching, affecting others not a party to the narrow “contract.”
Contracts ONLY affect the parties who agree to it. That doesn’t describe marriage.
That's not true. For example, third party beneficiaries can affect and be affected by a contract without ever being one of those who executed the original agreement.