Just as a chord can be built on the first note of a scale, it is possible to build chords on all the other notes of the scale. To build a chord on any note, you simply use that note to name the chord (e.g., D), and then add the note two letter names further up the scale (F) and then add the note two letter names above that (A). This would give you a chord containing the notes D, F and A.
The first note is called the root of the chord (D), the middle note is called the third (F) and the last note is called the fifth (A). Because of the uneven pattern of tones and semitones in the major scale, not all of these notes are the same distance apart.
For this reason, when you build chords on all the notes of the major scale, you end up with different types of chords. For example, the chord built on the first note of the C major scale is a C major chord, but the chord built on the second note is a D minor chord.
If you are interested in learning more about how chords are made from scales it is worth taking a few lessons from a good music teacher. Ask your local music store to recommend someone.
As you can see, just as there are major and minor scales, there are also major and minor chords. There are also many other types of chords all of which have different names and sounds. Each type has a different combination of notes and a specific chord formula.
If you look at most sheet music you will see chord symbols written above the melody, symbols such as C, Am, Bb7, E7#9, etc. All these symbols describe chords which have different types of sounds.
The reason a certain set of chords works well with a particular melody is that both the melody and the chords are made up of notes from the same key.
When putting a melody and chords together, the basic principle is that at the beginning of each bar or where there is a long sustained note, or any time there is a new chord, one of the notes of the chord played at that point should be the same note that is used in the melody at that point.
For example, if the melody has a G long note at the beginning of a bar, any chord used at that point should contain a G note. This doesn’t mean it has to be a G chord, it could be any chord which has G as one of its notes.
For example, a C chord or an E minor chord or an A7 chord all contain the note G. Understanding chords can be quite difficult at first and is a lot easier if you relate it to an instrument capable of playing chords (e.g., guitar or keyboard).