Q: What type of word is darin?
A: The group of words earlier known as Präpositionaladverbia s.a.
darin, worin, hierin / daran, woran, hieran / damit, womit, hiermit
is these days usually called
Pronominaladverbia,
and rarely
Adverbialpronomina.
The earlier name "Präpositionaladverbia" is referring to the way they are built by combining an adverb (da, wo, hier) with a preposition (in, an, mit). (The former becomes a locative adverb, the latter a prepositional adverb; together, they form a pronomial adverb.)
The current names refer to the adverbs function, which is pronomial in the sense that their locative adverbs (da, wo, hier) refer to something mentioned earlier, the way many pronouns do.
Most grammaticians call them Pronominaladverben and classify them as adverbs, some call them Adverbialpronomina and classify them as Pronomina because of their proxy function, which is similar to pronouns' proxy function.
Q: Are these words invariant?
A: Indeed, all pronomial adverbs are invariant. This means that they are never subject to any declension morphologically, but they are, as seen above, syntactically dependent of what they refer to.
In your example
Ich bin im Gebäude. = Ich bin darin.
the pronomial adverb darin (or more precisely, its locative adverb da) refers to Gebäude, and its prepositional adverb in specifying the position.
Note however that when in bears the meaning of a motion ("into"), s.a. in your second example
Ich gehe ins Gebäude. = Ich gehe da rein.
then the usage of darin, darein, da rein is very rare; vastly more common here is hinein.
Q: Is there a difference between its usages with transitive and intransitive verbs?
A: Your third and fourth examples arise around two different meanings of hängen, = to hang, one being a state, where the verb is intransitive:
Das Bild hängt an der Wand. = Das Bild hängt daran.
and the other one an action, where the verb is transitive:
Ich hänge das Bild an die Wand. = Ich hänge das Bild daran.
In both cases, daran is used correctly, and it (or any other Pronominaladverb) does not differ depending on the transitivity of the verb - or anything else for that matter, as they are, again, invariant.
Lastly, to quote your final question:
Q: Does the preposition stay as "daran" or does it change?
A: We have seen that they are not prepositions, but Pronominaladverben, = pronomial adverbs, and that No, they do not change, they are invariant.