Can someone please tell me that how is it possible that if the song is in e major then why there is a an fmajor chord in the song when there is no f major in emajor scale .please explain the theory..
Well, it much depends on context, especially if the context is rather "modal" or "tonal".
In your case, if the context is "modal", the song should have a strong Flamenco/Middle Eastern flavor, and the associated mode may be dominant Phrygian, see https://en.wikipedia.org/wiki/Phrygian_dominant_scale, i.e. here E, F, G#, A , B, C , D, E.
If the context is "tonal", then the chord F tonal function is a IIb, probably preparing the dominant V7 (here B) before a resolution on root E.
A rule of thumb is the following: "modal" and "tonal" both have a root or main tone, but "tonal" is mainly classical western /jazz music with potentially A LOT of alterations so that the concept of "scale" is not really relevant, whereas "modal" is commonly found in all non-western music and are associated with a given scale, almost no alterations and poor chord progressions.
You can have pretty exotic "scales" in modal music, not limited to our good old 7 steps major scale.
Tonal music is analyzed using dynamics of chord progressions. The typical basic block is the famous II V I (fifth cycle) with all the variants and alterations you can think of.
Blues is arguably in-between "modal" (Mississipi with blues scale) and "tonal" when it gets jazzy.
It's best to not be too contained in scale theory, it's very limiting. Think of the major scale as a guide to 'what sounds good' not 'what only sounds good.' In fact many musicians even deliberately create methods of not playing the right notes to make music sound pleasing for both chords and scales (mainly hexatonic type stuff). Such as:
Altered Chords, where a ♭5, ♯9, ♭9, ♯9, or ♭3 and ♮3 can be added to a chord to literally make the chord sound unbound to basic guides.
Tritone Substitutions and Coltrane changes.
Pentatonic Blues notes (both ♮3 & ♯4) are unbound to basic guides.
Bebop scales are common in jazz (especially bepop dorian) that contain passing notes that are unbound to basic guides.
Outside playing is an advanced jazz technique that uses the whole tone scale to get some awesome melodic type sounds. Hear it
There are so many other techniques that I have missed. The best way to some all of this up is a quote by Duke Ellington.
'If it sounds good, it IS good' - Duke Ellington