OK. So I love this question because there are a lot of ways that we can answer it, and depending on how much musical background you have, some of this ma y be more obvious than others. Based on how generalized this question is, I'm going to assume a pretty limited background, so I'll spend a little while covering the basics.
The question of what actually defines music is a necessarily messy one to answer, in the sort of way that all art has subjectivity behind it, but I think if you asked most people who engage with it even semi-professionally you'd get a consensus answer similar to "sounds arranged in time". That is, that we have sounds (including silence) and we have the durations they might play for. For a musical instrument, we'd think of this in terms of pitch/notes (i.e., what key on a piano we hit) and phrasing (which entails how intensely we hit the key, how long we hold it down for, etc.; while duration and volume are usually treated as separate concepts, especially in electronic music, they both relate to the way that the sound differentiates itself from both silence and other notes). These are the key to making a melody, which I think most of the people you'd get consensus from would say is the most basic element of "music", a melody being a series of notes of certain durations.
Melodies of course don't really exist on their own. The notes they're built out of come from what will probably be referred to as a "scale", especially if you're working from the European tradition. The prototypical example someone working in that tradition will give you is the C major scale, which can be played using the white keys on a piano. This scale can also be adjusted to play at different starting notes, which gives us the different diatonic modes, 'diatonic' just being a fancy word for being shaped like the major scale, the most notable of which is the minor scale, which you can get if you start from 'A' rather than 'C' on that same scale.
There's a lot I can cover here, but I bring up the scale to explain the short form of the answer: music defines itself in a harmonic context on the basis of its scale. Much in the way that an artist may have a small set of paints on their palette that are used to create shading and contrast between parts of a painting, a song is going to build from a certain selection of notes, its scale, and the harmonic context created by that scale will, at least intuitively, shape our interpretation of the notes within a melody. This is directly tied to a notion of "harmonic function" which in our major scale example has a lot to do with how the notes are actually arranged. Again, we're still working in an explicitly European tradition here, but some of the more high-level concepts will convey.
If you look at the piano in the example shown, you'll notice that there's a difference between the way "E" and "F" as well as "B" and "C" are spaced compared to the other notes -- there's no black key between them. There's a reason for this. The harmonic spacing between those two keys is the same as the spacing between the other notes and their succeeding black keys. That is, if you play the interval ('interval' being the technical term for the distance between notes in pitch) from "E" to "F" and then from "F" to the black key between "F" and "G" (which, in this case, we'll call "F-sharp" or "F♯", but could also call "G-flat" or "G♭"), they'll be the same interval. This goes the other way, too; going from F♯ to G is also that same interval, which means that the difference between F and G is two of this interval. We usually call the interval of the sort between F and G a "whole-step" and the difference between "E" and "F" a half-step, probably because there are more whole-steps than half-steps in the scale.
Because those half-step pairs are closer than the other notes in the scale, they tend to be more important melodically, and thus harmonically as well. However, I realize that I've gone this far and not really explained much about what I mean by harmony, and that requires at least a little bit of a digression.
When you hear even a single note played on just about every instrument, you technically hear more than one pitch. The reason that a saxophone sounds different from a trumpet sounds different from a piano sounds different from a xylophone, etc., is that each instrument has higher pitches that play in resonance with the one we associate with a note, at different levels of volume. The loudest, most prominent frequency, otherwise known as the 'fundamental', is the one that we would associate with the pitch; if we tried to sing so as to match the note we hit on the piano, we'd be singing, effectively, the same fundamental frequency. The other pitches we hear will all be higher frequency than this, and as a result, typically called "overtones"; they may also be called "harmonics", which is where we get the notion of harmony from.
Yes, in a way I'm working backwards with my explanation here. You see, the major scale actually arose as a way to organize the harmonic ratios of a note being played on an average instrument, which for the first several overtones of anything with an easily-determined pitch, are pretty consistent. These will show up as basic ratios of the fundamental frequency, like 2:1 (the octave), 3:2, 4:3, 5:4, etc. For a long time in history, this was how the major scale was actually defined, working backward from these ratios to define a scale, a system referred to as just intonation. Note that the higher the two numbers go the more likely they are to get dampened by the source of sound, due to how physics works, but how much they are dampened has a lot to do with how one instrument sounds over another.
As an aside, we don't regularly use just intonation as a means by which to define instruments today, though, because defining the ratios by means of a fundamental frequency means that the note ratios completely change when we change which note is our starting point. To manage consistency between starting notes, while keeping the important ratios close to their just-intonation ratios, musicians have in general agreed to a system where a semitone is fixed to 1/12 of the octave irrespective of starting note; we call this "twelve-tone equal temperament". Tuning systems and scales is, again, something that people spend their entire lives investigating, so this isn't and can't be an exhaustive investigation of that issue, but I felt this digression was at least a little necessary to keep our organization systems here from seeming too arbitrary.
Anyway, after the octave, the two main tones that are past the fundamental in just intonation are the 3:2 and 5:4 intervals. We can emphasize those intervals by playing the notes with fundamental frequencies in relationship with them; in C major these are the third and fifth notes of the scale, and we call this a C major chord. This is so fundamental to how we conceptualize harmony, as being, at its core, the root, third, and fifth of the scale for the scale's starting note, that it's how we start to conceptualize building chords within this scale, thinking of them as a root note, a third, and a fifth. If we start from C, F, and G, if we get the third note and fifth notes after them, we'll have a major chord from each -- the 'third' in the chord is four semitones up from the root; as you probably guessed, we call them major chords because they all have the same shape as the chord starting note of the major scale. The chords starting from D, E, and A will have the third be only three semitones from the note, and we call them minor chords. (These third intervals are called the "major" and "minor" third for this reason.)
Now, you'll notice that in the C chord in our scale, we have two notes in it that are separated from other scale tones by only a half step, as in B->C and E->F. Because the half-steps stand out, and are thus emphasized, they provide a good way for a melody to take us from something that isn't the C chord to notes that are in the C chord. In general we like to talk about these relationships, from going outside of a target chord into it, as "harmonic tension" and "[harmonic] release", because our root chord, C (implicitly, the C-major chord), sets our expectations of the scale.
(As a reminder, outside of the fact that the C scale uses only the white notes on the piano, we've have chosen it arbitrarily. As long as the 3rd-4th and 7th-root scale ratios are the half steps and everything else is a whole-step, we can choose whatever starting point for the scale we want and have a major scale out of it -- that the ratios will be consistent is, again, why equal-temperament is the standard for tuning in the modern era.)
When music theorists, composers, performers, etc. talk about "functional harmony", it's harmonies that emphasize these two melodic relationship sthat they're talking about, that these notes in particular lead back to the scale's root chord, and thus provide it with strong senses of harmonic direction. Thinking about melody in these terms will help to organize notes into something with more structure and flow. Organizing notes with structure and flow is what keeps a melodic sequence from feeling arbitrary. In terms of major chords in the scale, F is, of course, the root of the F (major) chord, and B is the third of the G chord. Thus we can use either of these chords to help us move our melody toward the root if it's not there, and similarly they are close enough to the root that they make good places to move toward if we want to get away from it.
As a note, you might notice that just as B is two notes away from G and D two notes away from B in our scale, F is two notes away from B. Maybe you're thinking that if we added the F to the G-major chord that it would give us a harmonic change that really wants to resolve to the C-major chord. Most musicians working in this European-based system of harmonic understanding would agree with you, that having both notes resolve their half-step to C is a very powerful resolution, to the point that this chord, which is a G chord plus the 7th note in the scale after G, the "dominant-7th" chord because of how much more emphasized this motion back to the root of scale is over any others -- like how we use C to refer to the C-major chord, we use G7 to refer to the G dominant-7th chord. The canonical example of a dominant-seventh chord resolving to a root is Twist and Shout.
The relationship between these two chords is the key concept behind functional harmony. In comparison, the relationship between F and C is called "subdominant" because only the F resolves by half-step, thus leading to a less-emphasized harmonic relationship. From this, we can start to think about chords as context for melody.
One thing that any blues musician would understand intuitively, if not necessarily say in these words, is that one very effective way to provide a context for a compelling melody is to start with a sequence of chords that you like. I can say this confidently because the vast, vast majority of blues songs use a specific chord sequence that is so linked to the genre that it is called the "12-bar blues". It provides a good example of how these chords can operate in sequence, because it only uses the three chords that we've talked about so far.
I'll use the '|' character to organize 'bars' -- these are a set of beats, most commonly in sets of four that help us to organize phrases -- of the chords that make up the 12-bar blues. In our C-major scale example, they'll look like this:
| C | C | C | C |
| F | F | C | C |
| G | F | C | C |
The phrasing of our melody is, for most blues songs, one that expresses a phase over those first four bars of the root chord. If we've built a phrase out of the chord tones of C ('chord tones' are, no surprise, the tones that make up a chord -- C, E, and G for a C-major chord), we might take that same phrase but make a couple changes, possibly switching the E and G to the close F and A in the F-major chord (F, A, and C make up the F-major chord), or we could keep the same melody line and have the change in chord change the context for the melodic phrase. Consider crosscut saw, boom boom boom boom, or stormy monday as examples of songs that follow this template
Blues is an intentional choice of something that breaks out semi-arbitrary rules, because it's built around an ambiguity of whether or not these are major or minor chords -- the blues was born on the guitar where even early blues musicians could pull minor thirds up to major thirds. Since both notes, as a result, show up in blues songs, we think of the scale that blues songs are made out of as being different from the major scale. So while the major scale was probably built out of an attempt to understand harmonics, nowadays we use scales as a means of analyzing music out of much broader traditions, and look far outside the diatonic one.
Another fun thing to note is that the 12-bar blues doesn't actually use dominant motion to resolve back to C, but subdominant motion, as it doesn't go from G->C but only ever F->C. This is because it's derived from African musical traditions where subdominant resolutions were more common. For long periods in European musical history the main use of this resolution was in chanted "amen" at the end of hymns set to prayers, to the point that it is frequently referred to as the "amen cadence", cadence being the term for a harmonic sequence meant to end in a sense of resolution; the movement from dominant to root is referred to as the "authentic cadence" because, again, it's considered to be the most complete movement from tension to release in a pair of chords within the major scale.
There are other examples of chord progressions that are basically definitional for entire genres of music. In our key of C, the chord progression | C | Am (A-minor) | F | G | would be the doo-wop progression; the so-called royal road progression would be something like | F | G7 | Em | Am | in C and can be heard in the chorus of Stevie Wonder's Saturn. There's also the 'axis' progression; this is, in C, built out of the chord sequence | C | G | F | Am | and very heavily used in pop-punk, but if you start halfway through the sequence, at F, you get a sequence that's been used for ballads for several decades and might be typified by the chorus of Rihanna's Umbrella. There are, of course, others, but in terms of modern pop music these are most of the ones you're likely to see.
Note that the linked pages on Wikipedia don't actually use chord names but Roman numerals -- that's a way of relating the chords from their root's distance from the scale root; i.e., 'I' means, in the key of C, C-major, and 'V' is G-major. Lowercase numerals refer to minor chords, such that "vi" would be A-minor in our examples. This allows us to account for changes in key; we could easily describe all these same chords by adding a "♯" to them, putting us in the key of C♯ instead; again, I've only chosen C in examples because it's easy to understand by looking at a piano.
This is, I realize, a lot of information in a single post. I'll try to summarize it all up in a few bullet points:
- Songs are able to take shape through contexts of melodic and harmonic direction
- Melodic direction comes from notes and phrasing; harmonic direction comes from chords
- Chord structure can help us come up with melodic phrases
- We express melodic and harmonic direction in terms of tension and release
- Chord progressions help us express tension and release in a sequence
- A lot of music is built out of existing chord-progressions because it makes the process much easier
This is a lot of information and I still feel like there's a lot of stuff that I probably should talk about, like implying harmonic direction only through a melody or examples of music that work outside of tension-release models but this is already a lot of information to throw at someone who might be coming in from a nearly-zero starting point of knowledge.
Hopefully this helps in some way to answer parts of this question!
