Those are common and useful tricks.
The way I'd explain the whole chord sequence is, it modulates between keys all the time:
- Dmaj7 : establishes D major as the key
- Am7 : gotcha! it wasn't D, it was G major!
- Gmaj7 : yeah ... see, I told you, it was G major.
- Bbmaj7 : oooops! the key is D minor! Fooled you twice!!
- Dmaj7 : ha ha ha! the key is in fact D major ! You're so easy to fool! ;)
If we just look at the Am7, there are many ways to look at it.
- You can see the Am there just as a fancy D7, because it has the C note
in it, the very thing that makes D7 push strongly towards G (using
the "V-I motion" mechanism).
- Or you can look at it as "simulating" or "borrowing" or whatever, pretending for a short while that you're in the key of G major, where the Am - D7 - G would be a II - V - I movement.
Try replacing the Am7 with a D7. Then try replacing it with a D11 (i.e. C6/D) ... almost the same? No? What's different? Then take any song that has a D7 - G movement, and replace the D7 with Am7. Same? Different?
One of my favourite chord sequences is in Skee-Lo's "I Wish", based on a sample from Bernard Wright's "Spinnin'" (AFAIK). In "C" it would go like this: Cmaj9 - Abmaj9 - Bmaj9 - Gmaj9 (repeat). It modulates between keys in a very juicy way.