The primary reasons for the cracking are rate of heat transfer and thermal expansion. This applies especially to brick,masonry and concrete which are quite brittle when put under tension.Heat transfer refers to how fast heat moves through a material and thermal expansion is the principle that most materials expand when heated and contract when cooled. In a wall if the materials are essentially locked into place and not able to freely expand the resulting changes in size can cause destuction of the wall. A more familiar example of this is in concrete highways and sidewalks. These materials are constructed with expansion joints to allow for the expansion and contraction to occur without the concrete being damaged.
In materials such as brick heat moves slowly through the material. Thus when hot water is poured onto the brick the surface becomes relatively hot compared to the remainder of the brick. This means the surface will want to expand more than the underlying brick and result in cracking.
likewise, if the surface is cooled quickly, it will contract compared to the underlying material and again cracking can occur.
The principle that causes thick walls to crack is that of expansion and contracction. When hot water is poured into something with thick walls, the layer closest to the heat source expands due to heating absorbtion. The outer layer of the walls do not absorb as much heat, thus don't expand at the same rate as the inner, causing cracking. The same is true of very cold water, except the inner walls contract due to the loss of heat. The outer walls don't contract as rapidly so cracking occurs. As the heat is transmitted, or the cold transmitted, through the thick walls, they lose heat or cold in the process, so the outer walls does not get as much heat or cold as the inner ones.