The Mercenary Magic Contract upgrade is part of the tier 3 Mercenary Third Contract upgrade, only available when allied with the Mercenary faction.
It allows you to choose the second faction spell. The first spell is available upon buying the Tier 1 Mercenary Magic Contract.
The choice of faction spells you get depends on the alignment you are playing. (e.g. The Night Time spell is only available to the evil alignment.)