How do instruments create sound with different pitches?
In order to understand how instruments create pitches, we need to understand how instruments create sound waves. There are two types of sound waves. Traveling waves are observed when a wave is not confined to a given space. If you were to shake an unattached, loose rope, the resulting random ripple in the rope would be a traveling wave. The wave could have any wavelength as there's nothing restricting the length.
Standing waves, on the other hand, occur when a wave is confined to a fixed space in a medium. The medium restricts the wavelength to hit recurring wavelengths and frequencies. If you were to shake a string that's attached to a pole, the resulting constrained ripple would be a standing wave.
This medium restriction produces a regular wave pattern that repeats. We call this a standing wave (as though it were standing still). You can see an example of a standing wave in the following figure: