Well for 1) Yes melodies do come from the scale of the key of the song, or scale of the chord you are on at that point in the song. So essentially, you can use the corresponding scales in whatever context you are in to create melodies.
2) Well in very basic terms yes you can spam out all the scales and modes and shapes you want in a key. And it will sound alright.
Besides scales and modes, there are arpeggios and intervals. Arpeggios are notes in a chord played separately. If you listen to classical and jazz and shred it is featured alot. Intervals are the distance that separates 2 notes from each other. So are C note to a A note is a minor third, or m3, interval. Some people like to colour their playing with sophisticated sounding intervallic playing. Eric Johnson after his pentatonic barrage in the opening solo on Cliffs of Dover is a famous one. Country guys use them alot too.
I presume you know what the modes are. If not, well I'm not that articulate enough to explain it to you. I will try.... The major scale are made up of 7 notes. So in C, its C-D-E-F-G-A-B-C, or 8 notes if you count the octave. For modal playing, each note has a scale that corresponds with the note's colour in regards to the root note. Thats how I feel it is and academics will probably give you a more grounded answer.
So C Major and its relative minor is Aminor right? Well both have the same notes, just starting on a different note. So same notes, same scale right? Right!
So if we move it up to G, which is the 5th of the C scale, you can use C major scale over a G and it will give you the G Mixolydian mode. Ok we will stop right there.
If you play these chords correspondingly, Cmajor, Dmin7, Emin7, F, G7, Amin7, Bm7b5, Cmajor, you will sound pretty awesome right? Because they are the chords that can be found in the C major scale. Play them across the neck, lengthwise. You will discover that even though your playing 8 different chords, they are ALL in one scale.
So 7 notes, 7 modes, 7 different sounds. In C, and now remember this, we are only talking about C, in C, C major is mode 1 or Ionian. D minor is 2 or Dorian, E minor is Phygrian, F major is Lydian, G7 or G dominant is Mixolydian, A minor is Aeolian, Bm7b5 is Locrian.
So!, when you are in E minor jamming, you can play E blues, Eminor or Aeolian, E Phrygrian, E Dorian, E diminished, E harmonic minor, E chromatic.....
Confused? I am. So, if your smarter then the average drummer, E Phrygian can also be seen as a C Major scale, E Aeolian a G major scale, E Dorian a Dmajor scale.
And don't worry if you need to remember all shapes. Because as guitarist, we are all not too bright and quite lazy but want to look flashy. All you need to do is learn a scale shape, and just transpose it appropriately to access the mode.
Do note however this is not the BEST way to learn modes. Because we are guitar players, we just wanna have fun. So this is a fun and easy way to go about it. BUT NOT the best. So if you really want to be good, ignore my post.
And one more trick, if you take a minor pentatonic shape, you realise there are alot of notes your not using inbetween your fingers? Thats where your Phygrian, Dorian, Mixolydian, whatever, are found. Go explore with your hands and ears!