If you're playing a C in C major and I'm playing a G, it may sound best if my G is close to a perfect fifth from your C in just intonation. This is why string sections often sound so sickly sweet, like A Capella.
On the other hand, if you are playing a C and a G on the piano, and I'm also playing a G, then it will sound best if I play the same G as you in 12-TET. If I were to play the "correct" G against your "wrong" G, it would sound out of tune.
Context is everything.
As you may notice, G doesn't have a sharp or a flat in C major! If string players relied upon accidentals to tell them how to tune a particular note, they would be out of luck seven twelfths of the time.
That process of adjustment: called intonation, happens after resolving which pitch class I want to play. It's not something that an arranger can control through the use of enharmonic spelling, but it doesn't stop them from trying!
The one exception is harmonics which are based upon integer ratios rather than 12-TET.