So I get that MIDIs aren't audio files. They're more of an archive of music notes. But how is it that all MIDI players manage to play the song with its original instruments, while editors like Logic Pro and MuseScore have to write their own instruments for it?
There is a standard called "General MIDI" which defines a standard set of 128 instruments. A MIDI file can contain up to 16 simultaneous "tracks," and the MIDI file contains commands to say which instrument should be used for each track.
The exact sounds of the instruments will be different for different MIDI players, but at least this means the notes that should be played on a trumpet or an electric guitar will sound something like the required instruments. The list of instruments is here.
The General MIDI standard is now more than 25 years old, and modern computers, smart phones, etc are much more powerful than when the standard was created. If you use a program like Logic Pro for music production, you will probably be using a much bigger sound library that doesn't conform to the General Midi standard. Instead of just one "trumpet" sound in General Midi, there may be 10 or more different trumpet sounds available, so you have to make your own choice about exactly which one you want to use.