How come “cheating” means “to be unfaithful to one’s spouse”?

I have heard this word frequently being used as an accusation of one person of having a secret and sexual affair with another person out of wedlock. But shouldn’t cheating supposed to mean stealing or plagiarizing data to advance in something, but that something does not bring any good to any party and can kick the cheater out of school? So, what is the connection between “cheating on a spouse” and “cheating to gain an unfair advantage”? How can one “cheat” in marriage?

Jukka