In order to store the new matrix with '42' at (3,1), MATLAB overwrites all matrix values after 3,1 and adds an additional row to the nonzero values vector and the row indices vectors.
Instead of using subscripted assignment, try using the sparse command to construct the matrix from the triplets. For example, suppose you wanted the sparse form of the coordinate matrix C: