I’m teaching my daughter some theory, so please let me know if this helps:
Let’s start way out at the 30,000ft view. In Western music we hear 12 different tones before we hear them repeat. Why 12? That’s for a separate discussion.
That said, we don’t like the way all 12 sound together, so we usually select a subset. There are several patterns you could choose from the 12, including five note patterns and eight note patterns. We call these “scales”. Again in Western music, there is a pattern of 7 notes we tend to like together, and five notes that we find a bit jarring. Nothing transcendent or magical about that pattern, it is just deeply rooted in our culture. We like that particular pattern so much, we call it the “major” scale and we painted those seven notes white on a keyboard and the other notes black.
You can start on any one of the 12 notes and play the same 7 note pattern and it will sound very similar (a big reason we have 12 notes to begin with). So much so that most people have no idea what key you are playing in. Whichever note you choose to start the pattern on is what we call the “key”. You can play the same piece in any key you wish and most audience members will never know.
Once you establish a “key” in your ear, certain notes tend to take on certain qualities. Some will feel more stable, some will want to move to the next note in the scale, some will feel uplifting and airy, some will feel dark, etc. Playing an entire song in one key will be very familiar and comfortable, if possibly a bit boring, to most Western listeners. The notes within the scale will have familiar roles and you can reliably build your melodies with those roles in mind.
So what if you don’t want a comfortable “major” feel to your song? One option is you can play the EXACT SAME pattern, but starting on different notes in the scale. You can force the listener to hear a new or different role of a particular note within the scale. For example, the seventh note in the scale pulls very strongly to the root (or its octave). But by emphasizing that you are playing the sixth note as your root the listener hears the seventh as much more stable and ambiguously pulling either up or down.
Playing the same major scale but emphasizing as the “root” note something other than the 1 is playing a “mode”. For example, if you are in the key of G, you could play the exact same notes as G major, just emphasizing the E as the root. How do you do that? By resolving phrases at the end of a bar on the E (Aeolian), or starting your phrases on the A (Dorian), or playing a triad starting on the D (Mixolydian) or the notes of a C arpeggio only on the down beats (Lydian). You can use rhythm to make the listener hear E as the root while playing the notes of G.
Or you can… This is where your artistry comes into play.
If you play that progression using the notes of the G major scales, but emphasize the A-C-E notes you will likely set up the listener to think they are hearing something in A Dorian. Emphasize the D-F#-A (without resolving to G) and the listener will hear D Mixo.
There are other ways you can spice up your melodies. You can change keys, rather than just modes. You can change modes over each chord to emphasize the harmonic movement of the song. You can borrow the mode of another key (for example using G Lydian, instead of G Ionian). But that all gets pretty complicated and advanced. For modes all you need to know is that you are playing the same notes, just emphasizing different notes to imply a different root.
Hope that helps.