Molotov-Ribbentrop Pact merely involves partitioning of Poland.
If that pact is considered an alliance, then what is generally sanitized as "Munich" or "Munich Conference" in Anglosphere would also constitute an alliance in between Britain and Germany, since it was about partitioning Czechoslovakia without even letting Czechoslovaks a chair at the conference table. Britain itself did not take any part of the country, but it gave approval to that partition and guaranteed non aggression against Germany due to the partition. But Anglo literature never calls it 'Munich Treaty' or 'Munich Pact' or 'Munich Alliance'; it is always called 'Munich', as if it was a rock concert or sports meet. At the time Britain (tories) were doing everything in their power to prevent any alliance against Germany in between France, Poland, Czechoslovakia and USSR, and even went to the extent of protesting when such an alliance potential appeared, saying "Germans will fear you are surrounding them!" and proceeded to prevent any alliance by individually going from country to country to diplomatically sabotage it. It was not so much a secret that Britain and its establishment (especially industrialists) wanted to use Germany against the rising threat of Soviet Union, lest it would empower social and economical demands of the people within Britain. (minimum wage, better working conditions, weekend vacation, 8 hour workday, retirement, social security etc).
This phenomenon is explained splendidly in one of small lectures of historian Michael Parenti, including circumstances leading to this situation:
Molotov-Ribbentrop pact was signed at the backdrop of this diplomatic scene, after all attempts of USSR for arranging any alliance against Germany was thwarted. On top of that, there were the territories Poland took from USSR during the civil war, and Soviets wanted those territories back. The final factor for the signing of the pact was Stalin's intent to delay a war in between USSR and Germany at whatever cost in order to give USSR time to prepare (no one doubted Germans would eventually want a war since they came to power in Germany by chanting "Death to communists" over one decade), and also put a buffer in between USSR and Germany in the form of Poland's territory.
Most important thing to notice is that its interestingly signed right after who was going to win the Battle of Khalkhin Gol in between USSR and Japan became clear, and under what conditions.
Khalkhin Gol affair easily explains what was the position of these two countries against each other - im going to quote from my answer on a relevant subject on Quora:
Battle of Khalkhin Gol as USSR vs Japanese starts in east asia at 11
May. The date is important, so please pay attention to it.
Anti Comintern pact was a pact signed in between Fascist countries
against 'Communist enemies'. That practically being USSR. Japan was
one of the axis countries and was in anti comintern pact. It was a
pact made explicitly against communist countries. That being USSR at
the time.So there is no way in hell german staff did not know about
what was about to transpire in Khalkhin Gol.
Japanese said the battle was because of a rogue general taking
initiative and initiating the conflict and Tokyo didn't have a hand in
it, but thats total bull - during 4 months Tokyo could have ordered
their general to stop or removed him. They didnt.
This means that this explanation is just an excuse japan government
used to test USSR before engaging in a full scale war. So we can
easily say that Nazis knew about Khalkhin Gol beforehand, and the test
was not only for Japan's ambitions, it was also a test of
anti-Comintern against USSR.
Things get interesting after this point; Khalkhin Gol lasts 4 months -
and Molotov-Ribbentropp pact is signed on august 23.
You can easily guess that by august, the rate Khalkin Gol battle was
going was evident - since 20 august was the date Zhukov started
Soviets' final attack which moped up the Japanese and ended the war.
So signing of Molotov-Ribbentrop pact is AFTER the final soviet
offensive starts in khalkin gol, at which point there was no mistaking
who won the confrontation and with what kind of result. Basically
soviets overran japanese, actually using the very tactics and
strategies they were going to use in beating the Nazis.
USSR and Germany could not have been allies by any legality, because USSR and Germany were already enemies due to Anti-Comintern pact.
Khalkhin Gol affair and Molotov-Ribbentrop pact's signing overlap - pact is signed only after it was evident that Soviets were going to win an overwhelming victory in Khalkhin Gol battle. Japan tested Soviets on behalf of anti-comintern pact, and they were found quite strong. And a direct offensive against USSR seeming impractical at that point in time.
It was a given that by attacking Poland, Germany would confront UK and France in actual war. Having USSR uncooperative, nervous or even hostile was not a good prospect. Thus, the incentive for some kind of neutrality.
Both parties had historical claims to various Polish land, USSR had a particular vengeance coming from 1919 invasion Poles did all the way to Ukraine with French support. Hence more incentive for the affair.
Neither Germany nor USSR could let the other take over Poland uncontested. It would be strategically dangerous, and also they would lose their claims to the lands they claimed. Therefore both sides needed to act. The best way to do this without risking conflict would be an agreement.
Therefore, we can easily say that there was no point in time in which these parties even felt as allies, leave aside actually being allies, and this affair was as it seems - an uneasy postponing of hostilities and resolution of a problem in which both parties had a stake in.
Nazis came to power by claiming to be defending 'western civilization against communism', and used the excuse of 'preventing communism from spreading' to sell their actions to the west in a lot of the annexations and moves they did in central Europe. They had the 'untermensch' label for the Slavs, they were in need of massive industrial resources, oil, manpower. They couldn't let an uncontested USSR build up their industry and military in their eastern border, which would have been suicide in their quest of dominating their 'lebensraum' - aka Europe.
Nazis knew this. Soviets knew this. Both sides knew that they were eventually going to go to war, and Soviets were preparing silently for it, keeping their preparations in the west to a minimum in order to not risk provoking Germans to a preemptive attack, whereas Germans were openly building for it.
The pact was just a postponing of the ultimate and inevitable conflict for convenience, and history has shown it to have been so.