The Soviet leadership, which hated the West, saw Nazi Germany as a suitable partner.
It is generally accepted that the treaty with Hitler helped to avoid the Nazi attack already in the autumn of 1939, to delay the war as much as possible and better prepare for it. In reality, the refusal to sign a treaty with Germany in August 1939 would not have harmed the security of the Soviet Union in the least.