From school, I remember a very important rule: first you need to pour the water and then the acid (when you need to mix them) not vice-versa. This is because otherwise the aсid becomes very hot and splashing may happen.

So, why does it get hotter when water is poured into it? What reaction takes place?

This is mostly the case for sulfuric acid. Commercially available sulfuric acid is dense (~1.8 g/ml) and when water is added, it may not mix. In this case a layer of hot weak acid solution is formed, which boils and sprays around. When acid is poured into water, it flows down the flask and mixes much better, so no boiling occurs.

The reason this occurs is due to the large amount of energy released in the hydration reaction of sulfuric acid ions. Do not believe that heat comes from dissociation, as the dissociation of acids, bases, and salts always consumes energy. The energy is released from subsequent hydration, and the release may be high, especially if $\ce{H+}$ or $\ce{OH-}$ ions are hydrated. 
