A border dispute does not change the fact they agreed to simultaneously invade and conquer Poland together.
It does not change the fact that the Nazi war machine would not have been able to function without Soviet supplies, which they continued to supply up until the moment Germany invaded.
It does not change the fact that the USSR helped Germany rebuild their military from locations within Russia.
You are ignoring basic facts.
I think that, not just you, but a lot of times when looking at historic events as big as the whole World Wars period sometimes we overlook many things.
The Nazis and the USSR were destined to collide, in the first place. This was so much a given that the Allies also tried to get a pact with the USSR during the Nazi appeasement phase of the pre-war. The only problem is that the USSR wanted Poland and continue restoring the parts of the Russian Empire that emancipated after WWI, and since the allies conceded already land to Nazi Germany, the USSR was not going to concede not taking Poland. The USSR signed the pact with the country that conceded what they wanted: Nazi Germany. It wasn't, in any talk, among the Allies, USSR, Nazi Germany, in whatever combination one may think, about ideological consensus. This is why whataboutism between the countries about who allied with who, for that time, it's pretty meaningless if you think about this away from the "black or white" perspective. We, knowing what the Nazis did, or the USSR did, or any involved country did, have a lot of hindsight and have another perspective about alliances, and I don't really think at that time the politicians were thinking in the same way, or believed that what ended happening would happen. Remember people even agreed to an Olympics in Nazi Germany, which they used for propaganda to keep a good image with the world and it actually worked even.
So yeah, the USSR and the Nazis signed a Non-aggression pact. Because they knew they couldn't fight a war on more than one front. You see, they all knew they would collide, by "they" I mean all major powers involved. France was an even bigger force than Germany, ready from the start, the fact that later they were defeated is another story, but France was very much prepared for war against Nazi Germany. France and the British Empire just set a moment on which it would happen: the invasion of Poland. But even this was not that important for the allies. Remember the Phony War phase? France and the British Empire got to actual war once France was invaded, the declaration of war after Poland was more about honoring their pact. The British Empire even invaded and occupied neutral Iceland, and was just beated by Nazi Germany in occupying Norway by a couple of days. So invading neutral countries really isn't moral grounds in this context.
I don't think the Allies wanted alliances with the USSR, or the other way around, because of them being "good guys", the fear of confrontation because of ideology was always there. They were common threats to each other. And that's the bigger thing. The inevitable war between the USSR and the Nazis was set on an ideological term, with or without pact. As some sort of confrontation between the western powers and the USSR, mainly stopped because of Nuclear disaster fear. It's easy to get this lost when dealing with the non-agression pact, historically speaking, it was them buying time before going to war with each other. Weirdly enough, Stalin did believe that Hitler would honor the document, despite everyone telling him, even the British Empire supplying information from the Enigma machines, that they would be invaded. But I digress.
Ultimately, Nazi Germany did invade, and the command from Hitler was to be ruthless, because it was ideological war above all else.
This is why Tankies aren't "right wing". Tankies are Stalinist, they defend Stalin, thinking that since his plans actually got the USSR to be a what it became, starting from an agrarian country, all the horrors were either justified (because, in tankie perspective, material history indicated that they were needed) or just imperial propaganda. A lot of tankies defend China or any left authoritarian country because they see the same justifications.
The problem with equating Nazis to Communism based on what Stalin did is that it really overlooks that Communism wasn't
owned by Stalin or the USSR. I don't think anyone can tell a Eastern European that they don't know what they talk about. The horrors of the USSR, specially the Stalin era, are very much historic fact. But Communism did took very different approaches in different places in the world. I can speak for myself, here in Chile, anti-communist sentiment, the idea of stopping the "Horrors of Communism in Europe", with a good chunk of help from the US, very much allowed thousands of people being murdered, tortured, kids to be kidnapped from their family, and a whole another can of horrors. Yeah, body count is low by comparison, but do we really want to start counting horrors as a way of measuring who's worse? Do we really want to relativice human rights so much?
Nazism, as an ideology, is violent and racist from the very foundation. That's the biggest difference and why is wrong to equate it with Communism. Again, I cannot deny the horrors lived by others, I can speak for myself saying that Communists here are very much moderate and democratic, except when under Pinochet.