First things first, MKV and AVI are both container files. They are the video equivalent of ZIP and RAR files, those extensions tell you nothing at all about the actual content of the file. Both of those containers can hold videos and sound encoded with any codec.
Clearly, in this case, either the header information in the original MKV is corrupted in some way, the file has been corrupted, or there is a bug in your converter and it can't properly deal with what ever codec is used within the MKV container.
B.