I mean the phenomenon that happens when a language borrows a word, but it gets replaced by a similar-sounding word that is already in the language like from Spanish 'aguacate' to 'avocado' or 'echeque mat' from French to 'check mate' in English?
Your examples are very different. While Spanish avocado might be an instance of folk etymology (history of Spanish is not my area of expertise and I don't feel comfortable commenting on this based on the OED), I will argue English checkmate is not.
Not sure why you think one word replaces the other in the case of checkmate. If we trust the OED, it says it was borrowed from Old French eschec , -ek , -eq , eschac. Loss of Anlaut e- in English in French borrowings is a well-known phonetic change, cf. squire - Old French esquier, escuier; scarf - Old Northern French escarpe etc.
Generally, what you’re trying to describe how a loan word may get changed is known as assimilation, which occurs because of the differences in phonetic/phonological constraints of the donor and recipient languages (this is standard terminology). Sometimes a loan word gets morphologically reanalyzed as well. All of those are different ways how a loan word may be integrated (or nativized) in the recipient language; cf. the screenshot below from Haspelmath 2009 (in Loanwords in the World's Languages: A Comparative Handbook)
This is called an "expressive loan": when a loanword is reanalyzed to fit into the patterns of the new language.
If an unfamiliar, archaic, or foreign word shifts into something meaningful in the new language, such as expatriate → ex-patriot or Alzheimer's Disease → old-timer's disease, then that's called an "eggcorn". And if the loanword keeps its original form but is given an incorrect etymology in the new language, that's a "folk etymology". There's significant overlap between these three.
I think you're referring to a "folk etymology", where the form or linguistic analysis of a word changes because people don't know the actual history of the word. Hence the original Nahuatl word for avocado "ahuakatl" → Spanish aguacate is attested in 1697 as "Avogato pear", subsequently avocato, avigato, avocado. "Avocado" is said to be influenced by Spanish avocado "lawyer".