AVI is the veteran of desktop video: dependable in 1995, cranky about everything invented since. It was born in 1992, Microsoft, and its real weak spot is modern life: no proper streaming, no subtitles, no love for modern codecs.
M4A is AAC in Apple's favorite outfit: the audio-only MP4 your iPhone speaks natively. An MP4 container holding only audio: usually AAC, occasionally Apple's lossless ALAC. That makes it the right destination when what you need is sounding great anywhere in the Apple ecosystem.