Please explain, so confusing. I get that AVC is a video format, MKV is a container (that can contain mp4 video, FLAC audio etc.), but what is mp4 then?
MP4 has not really an official meaning. But it adds a lot to the MPEG-confusion:
MPEG-4 part 14 container: takes an .mp4 file extension, therefore often just called MP4, if it contains audio, it can also have the .m4a extension, for video .m4v, and others (.m4p, .m4b, .m4r). the container format is a derivative of Apple QuickTime's container format (.mov).
MPEG-4 Part 2 codec: Most often just called MPEG-4, sometimes it also takes the name of the encoder software: Xvid, DivX... Became the first de facto standard for web video.
MPEG-4 Part 10 codec: also called MPEG-4 AVC and (ITU-T) H.264, and by the name of it's most popular encoder software: x264. De facto standard video codec today: Web, Blu-Ray, digital TV, camcorders (AVCHD standard), portable devices. Almost all of these devices ship today with H.264/AVC hardware codecs but rarely any other codec. It's successor is now coming to market, but just for fun they decided to give it another name: MPEG-H Part 2 also known as ITU-T H.265 or High Efficiency Video Coding (HEVC).
I'm not even going to start about all the other MPEGs :-)
MP4 is a container, not a video format. MP4 generally contains a variant of MPEG for the video, such as h.264 or generic MPEG-4. Sometimes they may contain an MPEG-2 or MPEG-1 stream, though that is pretty uncommon.