Localization of deformation and formation of residual stresses in metal-matrix composites