When you pluck a string, it vibrates and makes the saddle vibrate at the same frequency. The saddle then transmits the vibration to the soundboard through the bridge. Since the body is hollow, it forms a soundbox which can amplify this sound. After that, the sound comes out through the sound hole and is heard.
Four factors decide how a string makes a pitch, namely the string’s frequency: length, tension, density and thickness. Most acoustic guitars’ strings have the same length and similar tension but vary in density and thickness. The first string is like a thread; the sixth is like a wire. If you pluck a string, the thicker the lower pitch it will make. So the six strings with different lengths can make a series of pitches from high to low.
We have talked about the length affects the sound of a string. There are metal pieces cut into the neck called frets, which will change the vibrating length of strings if you press the strings down onto them. People find two notes harmonious if the first note’s frequency is two times of the second one’s and define the difference between them as an octave, which is further divided into 12 half steps. This is exactly how frets are arranged. Each of them divides the string’s remaining length by 21/12, making the notes increase by half steps.