zig zag scanning is a transform based coding .it is employed for nonuniform quantization of NxN DCT coefficients. Lower coefficients have most of the energy and it is distributed circularly symmetric about the origin.The net result is that , it results in 1D sequence, after certain number of non zero coefficients most of the remaining become 0.
The category/run length encoding is such that it counts the no. of consequtive zeroes in scanned sequence before coding a non-zero coefficient into a two part symbol sym1 and sym2. Sym1 is based on magnitude of coded coefficient and sym2 is based on no. of zeroes before non zero coefficient.
zig zag scanning, therefore , orders the DCT coefficients into an efficient manner for this category/run coding phase to take advantage of this structure.