In contemplation of means not in expectation of but with specific regard to the possibility of.
Parties expecting to marry might make or have made in the past agreements of all sorts--for instance, one party may be a vendor to the other party's firm, or they may have entered into a formal business partnership, or both may have been parties to an agreement settling a suit regarding a third party's will. At the time of those agreements they may or may not have expected to marry; but those agreements had no terms which explicitly referred to a marriage between the parties: they did not contemplate such a marriage. An ante-nuptial agreement, however, does contemplate the marriage of the parties to each other: it is executed with the intention of regulating the marriage they expect to enter into.
I have modified my first line to reflect the holding, in Cain v. Moon (1896), that a valid donatio mortis causa or deathbed gift “must have been made in contemplation, though not necessarily in expectation, of death.” [emphasis mine] That is, contemplation implies that the donor need not expect to die shortly, he must merely be considering that he may die shortly.