What is Codec?
A codec (coder–decoder) is the method used to compress and decompress audio or video.
The file type (MP4, MOV, WebM) is just a container; the codec inside decides quality and size. Common video codecs are H.264, H.265/HEVC, VP9 and AV1; common audio codecs are AAC, MP3 and Opus.
A video that won’t play usually means the player doesn’t support its codec, not its file extension.
Newer codecs (HEVC, AV1) make smaller files but need more processing power and aren’t supported everywhere.