How do I learn to recognise the notes, just by listening to some music being played? Is there some specific exercise for developing this skill? Also how to recognise the scales being played?
I am not sure if there are any written or universally recognized rules or not, but I follow some tricks that help me a lot to recognize the musical notes/chords.
By listening a song over and over again, you can get an initial idea of chord progression. You may listen the song in parts - for example: you can repeat the intro riff a number of times before you get the idea and move to the first para of the song.
Try to sing the song with your instrument
To get the idea of the scale, I try to 'sing' the song with my instrument (guitar) i.e. to play the lyrical part of the song by the instrument. If you can play the lyrical part by your instrument, you can check the notes you are playing. These notes give you the idea of the scale to be used for that part of the song. For example: if you need to play permutation of F, A, D, C notes to cover a part of the song, it tells that a Dm (D minor) or Dm7 chord may need to play over that part.
Listen to the notes one at a time
If you are covering an instrumental piece, you may get the idea of the scales used by listening a small part repeatedly and trying to recognize the notes one at a time. Everytime you repeat, you can try to recognize one note used in that part. Bass notes are easier to understand. Once you get sufficient number of notes for that part, you can get the scale easily.
This is an important practice that any musician should do on a regular basis. You should train your ear to recognize notes and chords. You can practice with your instrument - play any note on a keyboard without looking at it and try to recognize the note, play any two notes and try to recognize the interval. There are also a number of mobile apps available for ear training that you can play any time to train your ear.
90% of this comes down to experience and practice. Play a lot of music. READ a lot of music, don't just improvise. You'll come to recognise patterns, just as you did when learning to read words.