Why does my ID card oscillate sideways when walking?
As humans we oscillate left and right when we walk because we have two legs. You can get a resonance when the length of the cord is such that your pace matches the period of the swing.
(Like pushing a child on a swing a little higher each time they approach you.)
Whilst walking we also oscillate up and down - this can also contribute to driving the resonance.