The sounds from a guitar and sound from a flute can be differntiated by intensity, pitch, and tone.
If a guitar and a flute play notes of the same pitch and loudness, the sounds will still be quite distinct. This is because musical instruments do not vibrate at a single frequency. A given note involves vibrations at many different frequencies.
A flute is a wind instrument and produces a smooth sign wave, The flute sounds like a whistle but with too much vibrato.
The guitar strings produce more of a saw tooth wave. Guitar string tightly stretched. If we strum it, the energy from our finger is transferred to the string, causing it to vibrate. When the whole string vibrates, we hear the lowest pitch. Pitch helps us distinguish between low and high sounds.