The context is crucial when analyzing a piece of music. It’s only when considering the surrounding elements that the analysis makes sense.
For instance, interpreting the chord progression C-F-G-C as I-IV-V-I relies on the overall structure. Simply isolating F alone doesn’t reveal the key it belongs to.
Now look at the 2nd and 3rd bar; C♮ is used. This strongly indicates that the song is in principle based on natural minor rather than harmonic/melodic minor.
And of course, in the 1st bar, the note C♯, which determines the melodic minor, is not sounding. What can be observed is just that B♭ has changed to B♮.
With C♮ sounding in the vicinity while C♯ is not, in such a situation, it’s reasonable to consider the scale at this moment in G/D as Dorian.
Strictly speaking, since C♯ appears in the 7th bar, it’s not impossible to argue for the melodic minor in the G/D of the 5th bar. However, there are two points where the analysis lacks a bit of rigor:
1)The 5th measure clearly intends to repeat the 1st measure. Furthermore, the Dm7 at the beginning contains a C natural. In this context, stating that “the scale switches to melodic minor from the third beat” gives a rather patchy impression and is not a very elegant interpretation.
2)Please pay attention to the movement of the melodic note B♮. In the following bar, this note leaps down to G. The most typical movement of the 6th note in melodic minor is to ascend sequentially and return to the tonal center. Also, in melodic minor, it is a basic manner not to sharpen notes when descending.
With these premises in mind, the movement from B♮ to G appears not at all characteristic of melodic minor, but rather reminiscent of Dorian.