It changes because of the vowel coming after it. I think "gitmek" ("to go") is one of that small group of verbs that people started using before they invented grammar. So it's somewhat irregular; most languages have those. Gitmek and etmek are the two most important verbs that follow this pattern. Gitmek >> gidiyor; etmek >> ediyor. But this is definitely not the rule. Bitmek, itmek, tutmak, yatmak - just a few examples; the verb stems of these do not change from t to d. With other types of words, nouns, etc., this type of consonant change is wide-spread. There are simple rules describing the process. With verb stems, however, it is very rare.
The dative case ending is -(y)E (small vowel harmony).
For "where, from where, to where", the case endings get tacked onto a stem "nere".
So you have nerede "where? (locative)", nereye "to where? (dative)", and nereden "from where? (ablative)".
Similarly with "burada, buraya, buradan", "şurada, şuraya, şuradan", and "orada, oraya, oradan" for "(to/from) here" and "(to/from) there".