Well the simplest explanation is the classic nature vs. nurture, paired with selective breeding. If you are raised by hippie shroom eating chimp parents, you'll probably be attracted to a different sort of mate than if you are raised in a warrior clan. This sort of taming can happen within 3-4 generations and have permanent effects.
Dmitry Belyayev was able to produce a tame variety of the red fox within 4 generations of breeding: https://en.wikipedia.org/wiki/Dmitry_Belyayev_(zoologist)#Be...