in MacOS9 it is relatively easy to explain.
when a file was created in OS9, it has a resource fork (including what i believe is correct to call "info fork") where its type/creator code is stored.
that code can by empty, a general paceholder type of code, or unambiguously give information about the app it was created with and which type of file it is, like stCA/AIFC (cubase, aiff audio) or SIT5/SIT! (stuffit archive.)
the codes must be 4 character long, spaces are allowed, all-minorcase codes are reserved for apple inc.
four spaces means no code, ? ? ? ? means "prompt the user if possible", if the code is ABCD but there is no app which can open ABCD nothing will happen on launch.
most applications in OS9 otoh have a BNDL resource in their resourcefork, where they announce their signature (the creator code) and what types of files they are asking to be associated with, and then usually both a type code - and an icon - is present.
whenever an app is opened for the first time OS9 will be told and remember this info (in one of these invisble "desktop" files which sometimes do not update properly) and that info is fetched from there whenever a document is opened by doubleclick, by command-downarrow (or by applescript or via apple events)
there are only a few excpetions which outrule that creator code stuff which can be found in the files and apps themselves, when i am not wrong this is limited to the internet controlpanel and quicktime settings.
in OSX it is more complicated. it "understands" and uses type creator codes sometimes, but it also has two other methods, of which one of them are these "com.manufacturer.whatever" textfiles (i never understood this shit).
so in OSX it happens far more often that files show weird icons from wrong apps or ask for the program to be opened with despite of having the correct T/C info "built-in".
for example when i have a carbon audio plug-in in OSX which has a steinberg signature it will still open with spark because that audio host program has a newer date than cubase.
at the same time in OSX and windows this is a lesser problem becuse they are very good in interprerting what type of file it could be and offer you a list of programs which possibly can open it.
if a MacOS file´s info survive storage on foreign operating systems, file systems and/or a transfer over the net depends on these OSes, harddisk file systems or file transfer programs.
for example many linux servers will detect the MIME type of an AIFF file, and then you FTP client gets that info and might deliberately add creator:quicktime filetype: AIFF to the file.
filename extensions mean absolutely nothing on MacOS9. except for your eyes.
the majority of applications has content in the resourceforks (i.e. beside the info stuff, which is easy to redo), the majority of documents to not make use of that. so your programs in that screenshot are lost, your documents or stuffed programs are not.
making disc images to transfer files around is much faster than using compression.