There are already some short answers, I'll try a longer one.
You'd like to understand what happened. If you can do the following:
- (1) deal with or operate in the situation adequately
- (2) locate or recreate the situation at will
- (3) identify similar situations in other contexts
- (4) maybe even communicate and describe the situation to others
... then you "understand" the situation. (My own definition from the top of my head.) From what I can tell, you're not far from "understanding" the Fmaj7 chord in a D major context. You're able to recreate it, place it in a context ("locate" it), and even describe it to others! A lot of musicians would be perfectly happy with such a good level of understanding, and ask no further questions. :) But not you - you want more?
I guess what you're missing is somehow dealing with it, operating when the Fmaj7 chord is playing. For example, play other notes, solo or create melodies over it, meaning that you want to find notes and scales that would naturally fit over the chord. Maybe you tried using notes from the D major scale and it didn't really work? Or maybe you want to find similar patterns, examples of a similar phenomenon on a more abstract level, and that's why modal interchange was suggested. I agree, you can look at it as modal interchange.
Let's list a few "strategies" for finding things to play over the Fmaj7 chord.
- Do not try to find any scales. At least the chord notes work! I guess this is what Laurence suggested. You don't have to find a scale for every chord. But since you came here and asked the question, I guess you're not happy with that solution.
- Find a scale by holding the Fmaj7 chord and singing. I tried it without thinking and sang a D Dorian scale over it. Many musicians would be perfectly happy having found a scale to play over the chord. But you want more? You ask where did that come from, and what other alternatives are there?
- Try to explicate a scale by adding extensions to the chord in question. You have Fmaj7. Add a 9th, an 11th, and a 13th ... when you have the 13th, you have a full scale. Which ones did you add? Myself (and this is subjective) starting from F, A, C, E, ... 9th:G, 11th:B, 13th:D. I tried to add a Bb as the 11th (which would be in an F11 chord), but it sounded wrong for this progression. When I added B natural as the 11th, it sounded right for this context. This is in agreement with the D Dorian scale I sang: D, E, F, G, A, B, C are all in the extended chord.
- Try to identify chord roles and possible roles, including possible new tonics (modulation targets) when the Fmaj7 is sounding. Forget the D major context for a second. Play Fmaj7 - Em7 - Ebmaj7 - Dm7 - Dbmaj7 - Cm7 - Bmaj7 - Bbm7 - Amaj7 - G#m7 - Gmaj7 - F#m7 - ... and start over. Endless descending loop stepping through keys. Could the F#m7 - Fmaj7 utilize the same phenomenon as whatever it is that's happening in that long chain? So in other words, does the in-between chord Fmaj7 open up possibilities for a modulation to somewhere? (That's actually the same or similar thing as what happens in modal interchange) Where to? How about F#m7 - Fmaj7 - Emaj7? That would make E major the tonic, wouldn't it. Is that a similar chord step as in your example?
- Find other songs that have the same kind of progression and see what other people do over it. This is unfortunately not easy, if you haven't played a lot of music. That's why you should play a lot of music! Play jazz, soul, bossa nova, anything you can find that has interesting harmony. Look at what's happening - you automatically absorb harmonic patterns, even though you couldn't completely analyze them.