Marriage is a legal contract too, this just actually make marriage a more enforceable contract.
The best advice is to marry with care, seek legal advice, and get a strong and clear prenup. Even as one hopes for enduring romance and commitment, with the fickleness of the human heart and of judges, it makes sense to negotiate like a Medici and get a good lawyer if things go sour.