I'll talk about rocks only, although you might find that these concepts cross over to other materials. Initially the compression is due to compaction, cracks in the rock which are perpendicular to the max principal stress close up. Once these start closing up the curve goes up because the material is gretting stiffer. Then the rock will deform along a straight line, this is hookean deformation a bit like a spring. Then dilatancy will begin to dominate, cracks open up parallel to the maximum principal stress axis, the rock volume actually expands, this expansion is accommodated perpendicular to max stress. Along the max stress axis the rock will shorten, it becomes less stiff and under goes more strain per unit differential stress. Eventually the thing will reach max stress, if the rock is leading to shear failure the curve will roll over as the cracks align to form a fault plane. Then you get a sudden stress drop, this is associated with failure rather like an earthquake.