The point of learning all of these chords is to help visualize where the notes are on the guitar’s fretboard. If you look at all of the chord charts next to each other, and count the strings from right-to-left (this is common practice with guitar notation), you’ll see that the D chords (and FM7 in this book I’m using) don’t include notes on the 5th or 6th string.
We definitely want to remember where D is found on the 5th string so we can play a variation of the chord. A variation will include the same notes, but forms a different shape on the fretboard. So instead of having the DM7 chord’s root D on the 4th string, we can play the D on the 5th string and find the other notes (F# A C#) of the chords on other strings.
It’s very common to see variations of chords on guitar because of the way the instrument is made. A chord requires at least 3 notes and those 3 notes can be found in many instances on the fretboard. In the case of DM7, we can play D F# A C# F# instead of D A C# F# to engage the 5th string and the chord should sound the same.
Here are the variations of the chords that extend to the 5th string: