For example, in Mycenaean Greek, the word for king was Wanax or Anax, whereas the Modern Greek word for king is Basileus, nothing at all like Wanax. How did this happen & how do these kinds of changes occur in general?
For your specific example the rough outline is straightforward even if the exact details are largely unrecoverable: Mycenaean palaces were ruled by a wanax (Linear B 𐀷𐀙𐀏 wa-na-ka), and local chieftains called 𐀣𐀯𐀩𐀄 qa-si-re-u (/gʷasiléus/; Classical βασιλεύς) answered to him. With the Bronze Age collapse, the palaces disappeared and the figure of the wanax with them; the local leaders persisted and grew in prominence, and eventually their power grew to the point that the word for them came to mean, from our perspective, less "chieftain" and more "king".
The word wanax (Attic ἄναξ) didn't disappear, but it was now mainly applied to the historical wanaktes (now just heroes in epics, like Agamemnon) and gods. With the disappearance of actual wanaktes, the word just became somewhat marginal compared to the βασιλεῖς who still existed and held power (though it was eventually applied to certain royalty again, just in a different context).
As for general principles, there are a million reasons for semantic drift, and every word has a unique history. Sometimes it's down to material historical changes, sometimes it's just random drift. It's probably not possible to give a concise comprehensive answer.