I think what op meant was for example if a piano and a violin play notes of 512Hz, why do they sound different?
Take a guitar, for example. The resonant frequencies are:

. If you play the fundamental,

, then you can
simultaneously excite higher harmonics, such as n=2,3,4... etc. In fact, if you play any frequency, you will excite overtones of that frequency.
The degree to which these overtones are excited depends on the type of instrument, and in a sense defines the sound of the instrument. I remember seeing in year 12 that violins tended to excite much higher overtones than a piano, which is why they sounded more shrill. In fact, some of the higher overtones can sound rather bad, so in the really top-class instruments they use methods to cancel them out, such as pinching the string at a certain point to cancel out the standing wave of that particular harmonic, thus improving the sound quality of the instrument.