The Soviet Union voted in favor of a Jewish state during the UN Partition Plan, and recognized Israel days after it declared independence anticipating they would side with the Soviets. I understand that many, if not most of the early Zionists were secular and at the very least, leaned socialist, but other than that, I can't think of any reason. I guess another reason could be the disdain the Zionists had towards the British during the Mandate period could effect their attitude towards the US, but that's pretty flimsy. After it was clear Israel sided with the US, Stalin supported the Arabs.
I can say a few brief details and we will see if it satisfies the moderators.
First, there wasn't a solid indication that they would go with the USA. I will expand on some of the socialistic aspects next, but there are many official ways that this was communicated. From what I gather, there were some early indications that they would be part of the Non-Aligned Movement. Even in retrospect, it seems like they might have been not enticed away from the Non-Aligned Movement as much as they were repelled by an Arab neutralism that blamed the West for Israel's existence but found the Soviet alternative no better.
Second, those socialistic tendencies weren't isolated. They were present up to and including at the birth of Israel. Consider for instance, the highly successful Kibbutzim - this movement was largely inspired by a kind of utopian Zionist socialism. The USSR might have seen these nascent socialist tendencies as potentially Soviet-leaning elements of Israeli society who could tip the scales in their favour.
Third, there was a general tendency for at least a short time after WW2 for the USSR to treat its Jewish population, particularly Jews in occupied territories, well. In the same way that Christians in contemporary Syria might prefer Bashir al-Assad simply because the stability associated with the Syrian government tends to mean they aren't victims to random persecution like they are under some rebellion factions, it was hoped that Jews would fall into line more easily than other occupied populations. Being the least anti-semitic option in the field they might have hoped would buy them some soft power with the Israeli people. This didn't last exceptionally long for numerous reasons (for one, USSR state atheism), but I am not sure whether they might have still been keeping up that show of good will towards Eastern European Jews still when Israel was recognized.
The Soviet position was, as you've heard already, partly informed by ideological similarities and partly informed by geopolitics. However, I think I can expand on the situation slightly to explain the underlying context for both.
First, the ideological: the leaning socialist was not just a lean, it was a full-bore hug. Israel's first Prime Minister and most prominent founding father, David Ben-Gurion, was steeped in socialist movements. While he never displayed a deep knowledge of Marxist tenets, he was quite capable of understanding and arguing in support of them, especially on a surface level, and was quite supportive of the more centrally known tenets about class warfare. This preference for socialism was strengthened by the fact that the main opposition to Ben-Gurion, who never attained the level of popularity during his lifetime (and indeed perhaps ever), was the Revisionist movement's leader Vladimir Jabotinsky, who rejected socialism outright. The core of the Yishuv was secular and many folks were from Eastern Europe and the Soviet Union's territories, so socialism was actually a bit of a preference for them, favoring Ben-Gurion. At the same time, Ben-Gurion was more than willing to set aside socialism for the sake of creating a state; in a letter to his son, where his son asked why he didn't bring up class warfare at the 1935 Zionist Congress, Ben-Gurion responded that they had to establish so much (a state, economy, culture, etc.) that it was more important to unify than to discuss socialism which might alienate religious Zionist groups.
Still, the ideological affinity was not lost on the Soviets. After all, Ben-Gurion had spent many years trying to convince the Soviets to support Zionism, because it would make the Zionist movement in the Soviet Union more effective and powerful, thereby strengthening the ability to create a state. His efforts largely failed in the 1920s, but the Soviets changed their minds later on. This was, at least in part, and I emphasize the part because I believe the geopolitics was more important, due to the Holocaust. The Soviets devoted significant time explaining their pro-partition vote on the basis of Jewish suffering, but they were more likely motivated by the geopolitical aspect. The ideological similarities didn't hurt; Israeli kibbutzim signified a commitment to some level of socialism, as did the power of the labor movement in Israel. Thus, despite a deep dislike of Zionism, the Soviets at some points in the history discussed were willing to invest in Israel, hoping that it would turn out to be pro-Soviet.
To contrast with that was the ideological similarities, and non-similarities, with the West. The Zionist movement faced a significantly more hostile UK by the 1940s, despite the Holocaust, and one that did not want partition to pass. It faced a US that, while it had a friend in Truman, was pre-Truman tepid at best on the question. Zionist Jews remembered the King-Crane Commission and the history of US hesitancy on supporting a Jewish state, and equally recalled the antisemitism and anti-Zionism of the US State Department, which constantly fought with Truman to try and prevent him from supporting partition or a Jewish state. Most Jews in what became Israel did not come from the West, and far more came from Eastern Europe and Russia, and those who did sometimes reflected the Jewish populations of the West, which have historically been more amenable to socialism and the like.
On the back of this was the geopolitics. For one, the Soviets believed they could have their cake and eat it too; they didn't think supporting a Jewish state would harm their ability to work with the Arab states significantly, and that they could drop Israel if they did have to make a choice. Additionally, the US and UK were at odds by 1947/8 on a Jewish state, and the Soviets perceived an opportunity; they believed that if they could drive a wedge between the US and UK on the question of a Jewish state, it would only strengthen them in the long-term. The Middle East did indeed serve to divide the US and UK, but not so much on Zionism in the 1940s as in the 1950s, and not so much on Zionism itself as on the Arab-Israeli conflict, and relations with states like Egypt during the decolonization and withdrawal process of British forces from the reason (Churchill was, to put it mildly, very petty and bitter over Eisenhower's moves in the Middle East during this period, even pre-Suez, which he was not in power for). So the Soviet instinct did pan out in other areas, but failed to pan out quite as they'd hoped in such a US/UK division over Israel.
Additionally, part of the Soviet view was that the West itself was not entirely friendly to Israel anyways. The British, French, and US were not helpful in most ways to Israel during the 1948 War, and the Soviets saw an opportunity to make a friend in that as well. Those three placed an arms embargo on Israel, ostensibly to try and avoid and discourage fighting, but continued to fulfill existing arms contracts with the Arab states, creating a dichotomy between the two. The Soviets stepped into this gap and, through Czechoslovakia, sidestepped the arms embargo and sent extremely important weapons for the Jewish forces in 1948 that essentially gave them the means to push and create an advantage, and evened the field somewhat in armaments that the Arab states were much superior in. The Czechoslovakian arms transport was a serious boon in the Israeli war of independence, and the Soviets believed it was possible to take advantage of that opportunity to drive that wedge I mentioned but also to build on goodwill and perhaps create an ally too. It may even have worked, had the Soviets continued down this trend, but they refused to do so, and eventually France became the Western power most willing to provide arms to Israel, a pattern that lasted until around the 1967 War, after which the US stepped into France's former role and became solidly pro-Israel, whereas prior it had been somewhat ambiguous and hoped it could be friendly with both sides.
Stalin chose to side with the Arabs not because of Israel joining the US. Instead, I'd argue it was less the Israeli initiative and search than the confluence of factors such as rising antisemitism in the Soviet Union and yet another opportunity; Egypt had failed to procure requested funding and weapons from the US, so it turned to the Soviets. This led the West to arm Israel in response through France, and Israel played off fear of the Soviets to encourage this. As Shimon Peres, one of Israel's other founding fathers and a huge figure in Israeli history, recalled, the atmosphere of the 1940s and 50s was that the Soviets might be friendly, if at least in part because many of the members of the Soviet Politburo were Jewish, and "some of our people deluded themselves into thinking that this 'Jewish connection' in the Soviet Union could somehow work in our favor". Of course, Peres recalled, Stalin later killed most of them anyways. But the attempt to create some kind of connection eventually ran into a roadblock, and Israel was seen as a less lucrative ally, and a Jewish one too, and the Soviet antisemitism that Ben-Gurion had seen and known of for decades was simply insurmountable for both sides, as was the geopolitics.
Because nothing precluded the Israelis from allying with the USSR. In fact, the majority of European Jews that came to Israel came from Eastern Europe, and many Jewish intellectuals (who later went to Israel) were instrumental in the Marxist ideology (Kibbutz in Israel, etc), many of which having left a large legacy in the Israeli left wing.
Israel is an independent state and back in the day it was not the "51st State" of the USA by any means. It turned to any large powerful nation if it was willing to help, as Israel was in a precarious position as a young state.
Also, after WW2, the US admin was not necessarily pro-Israel and pro-Jewish. Eisenhower looked at Israel warily and the US were more of a neutral player in the region, trying to calm both sides and even siding with the Arabs on a number of occasions. At this time, France was probably Israel's greatest ally (since France was anti-Arab as it tried to keep its Empire in the Arab world).
It took only until the LBJ admin to really get the modern pro-Israel/Zionist policy in the United States. The same policy which really alienated the Arab world regarding the USA.