This one is a bit confusing.
William was Sovereign Prince of Orange from his birth (in 1650), but the territory of the Principality was annexed to France in 1673, after which the title was nominal only. William didn’t marry Mary until 1677, so he wasn’t then the sovereign ruler (or the ruler in any sense) of Orange.
Nor, for that matter, was Mary a sovereign or a ruler; she was but a humble princess. England and Scotland at the time were ruled by her uncle, Charles I and, while it was possible that she would inherit the thrones, it was pretty unlikely. She only succeeded to the throne 12 years later, when parliament intervened to deem her father, James II, to have abdicated, and to exclude her brother, James Francis, from the succession.
William was, at the time of the marriage, Stadhouder of Holland, Zeeland, Utrecht and several other Netherlandish provinces. The Stadhouder was orginally a kind of Lord Lieutenant, appointed to represent the Duke of Burgundy (the sovereign) in the province. (This was necessary because the Duke had bigger fish to fry elsewhere, when he became Emperor and also King of Spain.) About a century before William’s time the Netherlandish provinces had successfully rebelled and declared themselves a republic. Stadhouders continued to be appointed but they now acted on behalf not of the Duke of Burgundy, but of the States (parliament) of the province. It was the States which appointed the stadhouder of each province.
It was not uncommon for the same person to be appointed stadhouder of more than one province. Over time, in practice the office of stadhouder became hereditary in one family, so the option open to a province was (a) appoint the head of that family, or (b) appoint no stadhouder. At the time of his marriage William was stadhouder of five out of (I think) seven provinces. (Hendrik-Casimir II of Nassau was stadhouder of the other two.)
The stadhouder technically was not a sovereign, but he was the chief executive, and I think it’s fair to call William the ruler of the Netherlands, and certainly fair to call him the rule of the five provinces of which he was stadhouder. But it wasn’t until 12 years later, in 1689, that Mary became Queen of England and Scotland (and William became King of England and Scotland, while continuing on as stadhouder). Only then do you have the rulers of two countries married to one another.
And, not be indelicate or anything, but it’s not certain that William and Mary were still having sex at that point. Mary’s last pregnancy was in 1680, when she was 18, and from that time on William is known to have kept Elizabeth Villiers as his mistress, while his enemies alleged that he was homosexual. Mary died in 1694 at the age of 32.