Back in the day, this worked via a flag in the metadata for each file. When you got a new executable, the flag was unset. The OS would see a file with an unset flag, ask “Is this an executable? What files can it open?” and then add this information to a database called the desktop database.
This is why file associations work on a Mac without an installer, and without writing any code (you just have to write the code for “open file in response to OS request”).