No, you don't have to play it with that exact fingering. In fact, being able to play the same chord shape in different ways can come in handy when you have to play modified versions of base chords.
For instance, say you had to play a D/F# chord (that same D with an F# bass note). One way to do it is to use your index finger on the 2nd fret of the E string, which leaves fingers 2-4 to play the basic D chord shape. Another example is if you had to move that D shape up on the fretboard, using the index finger to do a barré and again leaving fingers 2-4 for the basic chord shape.
Yet another reason to choose a different fingering for a chord is if it makes it easier to transition from the previous (or to the next) chord in a song. For instance, the most often recommended fingering for the G-major chord is using fingers 1-3, but using fingers 2-4 makes it easier to transition to (or from) the C-major chord because the middle and ring fingers have to move very little (plus it leaves your index finger hovering more or less above the correct string as well).