It's not just a pure single frequency of sound that is being transmitted by an instrument. Just like with light, if you ask the frequency of the sun's emission, the answer would be that it's a whole broad spectrum (hence its ability to produce a rainbow, or allow objects to reflect colours other than yellow) but its peak frequency is yellow. You can ask for a distribution of the colours (or light frequencies) that it transmits, and you'll get a plot of intensity vs light frequency (this is also known as the Fourier Transform of the plot of the actual amplitude of light waves travelling from the sun)... the plot will peak at the frequency represented by yellow light.
You will see something similar for a sound note. If you look at the Fourier transform of the middle C played by a piano string (approximately 262 Hz), you will see a plot with a bunch of hills and valleys, the tallest hill peaking at 262 Hz, the second tallest at 524 Hz, the third tallest at 786 Hz, etc (note that they are integer multiples of the note itself) but those hills will have some shape to them meaning that other frequencies outside of the peak note are represented in the note itself. It's the shape of those hills (as well as the ratio of the peak of those hills to the following integer multiple peaks) that determine the style of the sound.