The reason the same letter in music does not always refer to the same note for every instrument has to do with the concept of transposition. Transposition refers to the process of shifting a piece of music or a specific instrument's pitch range up or down without changing the relative intervals between the notes.
Different instruments are designed with various ranges and tunings, which means that the same written note (letter) may produce a different pitch when played on different instruments. This is particularly true for instruments in different families, such as brass, woodwind, or strings.
For example, in your question, you mentioned that a trumpet playing a C sounds like a flute playing a B-flat. The trumpet is a transposing instrument, typically notated in the key of B-flat or C. When a trumpet player reads a C on the sheet music and plays it, the actual pitch produced is a B-flat. This means that the trumpet sounds a whole step lower than written.
On the other hand, the flute is a non-transposing instrument. When a flutist reads a written B-flat on the sheet music and plays it, the actual pitch produced is a B-flat. Therefore, the flute sounds the pitch as written.
The reason for these transpositions and differences in pitch is mainly historical and practical. Certain instruments were developed at different times and in different regions, and the transpositions helped to standardize the fingerings and make it easier for musicians to switch between instruments.
It's worth noting that while many instruments have standard transpositions, there are also exceptions and variations. This can add complexity to orchestration and music composition, but it also offers flexibility and unique timbral possibilities when combining different instruments together.