Is file name extension related to file format?

usually unless you change the extesion for exaple mp4 mp3 flacc are all audio files but all different formats or codecs