The reason for the segmentation fault is, that you're allocating a 2D array but there is no guarantee that it uses contiguous memory. So, allocate a 1D array and scatter/gather it. This also explains why some nodes get the wrong data.
You named the receiving variable status
which I find misleading, since it'll hold the received value(s). So you'll have to allocate it correctly for the case when a node receives more then one value. Also I'd suggest to rename it to e.g. local_matrix
or similar.
Side node: You allocate matrix
on all nodes, but you should only allocate on a single node. This can be done by checking the current rank and placing a barrier after the check. Furthermore, I assume that you also print on all nodes, but this code isn't visible. As with the allocation, print should done as well only on one node.
Also have a look at How are MPI_Scatter and MPI_Gather used from C? which explains it pretty well.