In Unix a file is just a sequence of bytes, however some files have more structure. The
file command can look at the sequence of bytes and tell you things.for example if the first 4bytes are \177 E L F then it will tell you it is an elf file. It will then look at more bytes and tell you if it is a core file, an executable or an object file. If the bytes 6 thru 9 are JFIF then it is a picture file and again the program can read more and tell you about it.
A lot of this is driven by data tables rather than being compiled into the program. These data tables are what is in the
So the reason why you have magic files is to allow you to say
file * and get the program to tell you what you have in the current directory.