The Sharingan itself originated from the Ten Tails, he had what I like to call a "Sharinnegan", a Rinngean rippled eye, with Sharingan marks on each ripple.
The Sage of Six Paths inherited that power when he became the Ten Tails' Jinchuuriki, which was then genetically passed to his eldest son.
From my understanding, Sharingan is considered the Yin, while the Senju vitality and life force is considered the Yang. They are two halfs of the same whole, which is why a combination of the two can achieve the ultimate power.
Aside from that, "normal" elemental Kekkei Genkai is the result of a specific bloodline being born with two (or more in some cases) elements. This results easy manipulation and fusion of both elements, into the new Kekkei Genkai. These were probably learned/created early in the bloodline, and then taught to new members when they came of age.
There are also other Kekkei Genkai, like Kimimaro's bone jutsu, and Suigetsu liquefaction jutsu. These aren't explained in much detail, but they are probably some sort of genetic mutation which enabled their chakra to preform these techniques. Because it's a genetic mutation, only those bloodline members can use it.
There were expirments in Kekkei Genkai transfer and the results were inconclousive. It was seen that the Sharingan and even the Rinnegan can be succesfully transplanted and operated in the new host quite easily. However, when Orochimaru attempted to transplant Hashirama's cells into newborns, only one out of fifty survived and accepted the cells.