What is a word with two opposite meanings, like 'cleave' or 'sanction', called?
Context tells you which meaning is intended.
Linguists sort these words into a few different pathways. Some are really two unrelated words that happen to look identical. 'Cleave' is the classic case: one verb descends from Old English cleofan, 'to split', and another from clifian, 'to stick to'. Over centuries their spellings and inflections merged, so a single written form now carries both 'separate' and 'join'. 'Clip' works the same way, with one verb meaning 'fasten together' and another meaning 'cut off'.
Other contronyms come from a single word whose sense branched in two directions. 'Sanction' entered English around the idea of a binding oath or decree, and later split into 'give official approval' and 'impose a penalty'. 'Oversight' can mean careful supervision or a failure to notice something. 'Fast' can mean firmly fixed in place or moving quickly, and Merriam-Webster notes that the word has been used in both ways since roughly the 13th century, although how 'firm' became 'swift' is not fully settled.
The category is small, and the names vary: contronym, contranym, antagonym, auto-antonym and Janus word (after the two-faced Roman god) all circulate. Because the intended meaning almost always comes from context, readers rarely get confused in practice, which is probably why these words survive. A common misconception is that every word with several meanings counts; a true contronym needs two senses that are opposites, not merely different.