North Dakota is just Minnesota without the Twin Cities, so of course it would vote Democratic occasionally.
Eastern South Dakota is the same, while west of the Missouri River is Wyomingish. East River is far more politically moderate, and West River is very conservative. However, West River is also more libertarian, and voters there rejected a proposed abortion ban more overwhelmingly than the more moralistic East River voters.
Eastern Montana is actually quite similar to North Dakota. It's not as linked to Minnesota, but a large part of Montana is kind of Midwestern. Demographically, Montana is the fourth most Norwegian State, and the seventh most Lutheran state. There is Midwestern influence in the state and it is arguably as similar to South Dakota as it is to Wyoming. That may explain why it often votes similar to the Dakotas.
To simplify these four states, North Dakota is mostly Midwestern and Wyoming is a heavily Western, cowboyish state; Wyoming could be Colorado without Denver. South Dakota is predominately Midwestern with a strong touch of the West. Montana is also a mix of the two regions, a little more Western. I've been around the region; the Black Hills are clearly the Wild West. If you go to the wheat fields of eastern Montana, you would never know that you were in a state famous for mountains.
I went off a little tangent, but I thought I'd share this perspective as someone who lives in the region. The area has traditionally been independent minded, but the four states will probably trend more Republican. Now that Tim Johnson is retiring, Republicans will likely control all of the major offices soon.