I'm learning Japanese, but I'm a beginner, and I need to understand why this kanji is a compound of the kanji for "horse" and "deer":
馬鹿 = idiot
馬 = horse
鹿 = deer
Why?
馬鹿 is an ateji, which means either the readings of the individual kanji do not match the reading of the word, or the meanings of the individual kanji do not match the meaning of the word. In this case, it's the latter - why would an idiot be described as a horse and/or a deer?
As for why these particular kanji were chosen to represent ばか, the etymology is unclear. See this webpage for several theories. https://www.tofugu.com/japanese/baka-meaning/
In this case, the individual kanji meanings were forgone. Other ateji include 時計{とけい} (readings forgone), 真面目{まじめ} (readings forgone), 七夕{たなばた} (readings forgone), 寿司{すし} (meanings forgone), etc.
馬鹿 is also written as 莫迦. Based on 岩波書店’s 広辞苑, it was originally a Buddhist terminology derived from Sanskrit, either “moka –phonetically transcribed as 慕何 in Kanji” meaning ‘stupidity,’ or “mahaliaka – phonetically transcribed as 魔訶羅 meaning ‘ignorance’ - the source: 文明節用集 – Bunmei Glossary published in 文明6年(1474 ).
The letter of 馬 is read and vocalized as “ba,” and 鹿 is read and vocalized as “ka” both in 音読み. So its combination is バカ - baka.
Both 馬鹿 and 莫迦 are arbitrary adoption to 慕何 or 魔訶羅, which might have taken place before 15 century. Horse and deer have nothing to do with what 馬鹿 really means