This tune is in the key of D ionian. Therefore the available chords are D major, E minor, F# minor, G major, A major, B minor and C# diminished.
If you listen to the tune my choices should be relatively self-explanatory. Notice that each section ends with a resolution from A D, aka chord V to chord I.
I have substituted the G in the second line for its related minor, Em. I have also substituted the D in the second half of the third line for its related minor, Bm and the G in the final line for Em.
In the second line of the B part I have replaced one D chord with a D in the first inversion (D/F#). This chord still contains the notes of a D major triad, D, F# and A, but has them piled up with the F# at the lowest pitch within the chord. This means that functionally it is exactly the same as a normal D major chord, but it’s altered bass note creates a nice bassline which adds a sense of movement to the progression, jumping from D to F# before dropping back down for the E at the bottom of the E minor chord which follows it. In the third line I have used a similar trick to link a G chord to it’s related minor E minor, passing through D/F# in order to make a nice descending bassline, G, F#, E.
Because of the excessive speed at which polkas roll along, I have kept my chord choices relatively simple for this one! If you’re feeling jazzy, you can replace any chord with the “right kind” of seven chord, by which I mean that in the ionian mode chords I and IV can become major 7 chords, chords II, III and VI become minor 7 chords and chord V becomes a dominant 7 chord (usually just referred to as a 7 chord). This is why my Em7, A7 (this is chord V so it has to be “A7” NOT “A major 7”) and Bm7 all work well.
In the B part I have added a C natural (♮) chord- this is decidedly cheeky. What I have actually done there is to borrow a chord from the mixolydian mode, which is only separated from the ionian mode by one note. If this tune were written in D mixolydian, its scale would contain a C♮ instead of C#, and therefore its VII chord would be C major instead of C# diminished. As the 7th note of the scale, C#, is not in the melody in this bar I can borrow the cheeky flattened VII chord from D mixolydian. So long as there is no C# in the tune it won’t clash but will just lend the tune a blues-y character for a moment instead!
Changing the third line from “D D G G” to “Bm7 A7 G D/F#” works because Bm is related to D (and therefore so is Bm7), A7 is a passing chord which creates a nice step-wise descent to G and then D/F# is chord I (D) but with a bass note which continues the little descending bass run, which then culminates in E minor in the final line.