How is it that a Sharingan can work when it's been transplanted?
Let's disregard the fact that eyes in Naruto are considered less difficult to work with than PnP displays. (Rin did it in a cave, without any medical supplies, in a couple of seconds, and it just worked)

Your eyes contain your DNA, so our (the Uchiha) eyes contain the already awakened Sharingan, it's written into the DNA.

It also has the genetic information allowing you to activate the techniques the eye holds (including Mangekyo).