Dear student,
The sound produced by two different instruments can vary if the quality of sound differs. And we know, quality of sound depends on wave form. As the waveform produced by the flute is different from that of the violin, hence the quality of sound differs. That's why even if the two instruments are playing in same frequency, we can differentiate between these two sounds.
Regards,