The OED specifies 16 principal meanings of the word mistress, and in addition many sub-meanings. The two to which you refer are included in that number.
It is sense 2a which refers to a wife.
a. The female head of a family, household, or other establishment; a
woman holding such a position in conjunction with a male counterpart.
The examples given are as follows. You will notice that the those containing the term mistress as opposed to Mrs are very sparse since the 19th century.
a1375 William of Palerne (1867) 1016 (MED), Alisaundrine..attlede
þe soþe, þat hire maistres & þat man no schuld hire nouȝt misse, þeȝh
sche walked..from here siȝt.
a1425 Rule St. Benet (Lansd.) (1902) 10 (MED), Ilkain sal take
discipline at oþir, als hir mastiresse þoȝ scho ware.
1483 (▸1413) Pilgrimage of Soul (Caxton) iv. xxxviii. 64 She
bare hyr seluen boldely, right as she were maystresse, and hadde alle
the gouernement of the kyng, and his houshold.
a1513 H. Bradshaw Lyfe St. Werburge (1521) i.xxi. sig. g.viiiv, Of
whiche sayd places [sc. monasteries], she had the gouernaunce As
worthy maystres.
1584–5 in J. D. Marwick Extracts Rec. Burgh Edinb. (1882) IV. 400
The maister or maistres of euery house.
1611 Bible (King James) 1 Kings xvii. 17 The sonne of the woman,
the mistresse of the house, fell sicke.
1641 J. Jackson True Evangelical Temper iii. 225 The Mistris is a
good Huswife, but of shrewish condition.
1711 R. Steele Spectator No. 202. ⁋ 12 That the Masters and
Mistresses of such Houses live in continual Suspicion of their
ingenuous and true Servants.
1773 H. Chapone Lett. Improvem. Mind II. 72 The mistress of the
family must be ever watchful.
1814 Scott Waverley III. vi. 80 The future mistress of my family,
and the mother of my children.
1861 F. Nightingale Notes on Nursing (new ed.) ii. 24 The mistress
of any building, large or small, does not think it necessary to visit
every hole and corner of it every day.
1896 J. M. Barrie Margaret Ogilvy ii. 27 She was eight when her
mother's death made her mistress of the house and mother to her little
brother.
1921 A. Huxley Crome Yellow 131 The young lady accepted him, and
in less than a year had become the absolute mistress of Crome and her
husband.
1997 P. Carey Jack Maggs xlii. 151 It was as clear as day to her
that she..might one day be mistress of the house wherein she had been
called to serve.
The other meaning to which you have referred is number 7.
> 7. A woman other than his wife with whom a man has a long-lasting sexual relationship. In early use: †a woman notorious for some act (obs.).>
There are entries for this from as early as the 15th century.