M4A is AAC in Apple's favorite outfit: the audio-only MP4 your iPhone speaks natively. It was born in 2003, popularized by Apple's iTunes Store, and its real weak spot is older Windows software and stubborn car stereos that expect a .mp3.
MKV is the format that hoards: video, a dozen audio tracks and every subtitle, all in one box. The Matroska container: it will hold practically any codec ever made. That makes it the right destination when what you need is high-quality rips and archives with multiple audio and subtitle tracks.