Marx teaches that the proletariat in industrialized cities were the only groups with revolutionary consciousness. Yet, whenever communism took root and caused revolutions, it was agricultural societies, led by armies of peasants. Tsarist Russia, Imperial China, French Vietnam, Batistan Cuba, and on and on. Am I missing something? Where's the connection?
Speaking specifically to the case of Cuba, it's a bit more complicated than that.
The uprising against Batista was not Communist. The Cuban Revolution wasn't declared to be 'Communist' by Fidel until 1961, right before the Bay of Pigs invasion. In fact, Fidel went out of his way to make sure people understood that the Revolution would be 'green like the palm trees [e.g. a traditional Cuban symbol], and never red [e.g. Communist]'.
In addition, Fidel's 26 of July Movement in the Sierra Maestra (a mountain range in Eastern Cuba) was only one among many movements. There was important urban guerrilla warfare, including the Directorio (Directorate), an urban underground organization deeply linked to student radicals, and which went so far as to attempt to assassinate Batista by driving a coffee truck through the doors of the Presidential Palace (Pre-Revolutionary Cuba's equivalent of the White House). The final assailant died just outside Batista's office.
Fidel's landing in Cuba, on the yacht called Granma, coincided with a major uprising in Santiago de Cuba, which was quickly and brutally repressed by the Batista regime.
In Cuba, urban guerrilla warfare during that period is known as el llano (the plains), as opposed to those fighting in rural areas, which is referred to as la sierra (the mountains).
Even the 26 of July Movement itself was very heterogeneous, with Communists like Ernesto "Che" Guevara being outnumbered by center Left nationalists, like Huber Matos.
In fact, the Communist party of Cuba, which then went by the name Partido Socialista Popular (Popular Socialist Party or PSP), called Fidel a bourgeois adventurer and didn't back him until really late in the game, on or about 1958.
It was only after Fidel came into power that he embraced the USSR and Communism as the official goal of the Revolution. This caused internal divisions within the Revolution, such as the arrest and jailing of Huber Matos and other moderates who refused to participate in an openly Socialist government.
Hence a narrative of the Revolution being betrayed; Fidel had promised one kind of Revolution, but implemented a different one.
There is a huge debate over Fidel's motives, between those who say this had been his plan all along and those who point to the embrace of Communism and the USSR as a purely pragmatic decision fueled by US attempts to overthrow the Revolution.
The Eisenhower administration had been pushing for a third option in 1958, trying to convince Batista to abandon the country early enough that Washington could push for an acceptable middle of the road candidate who wasn't Castro (whose agrarian reform program threatened established US interests on the island). The first half of 1959 was comprised of attempts by the Eisenhower administration to determine if they could rely on Castro to 'play ball', as it were, and soften parts of his program which threatened US business interests. By late 1959, however, it had already been determined that Castro wasn't to be trusted and that his ouster was the best solution. This stance eventually produced the disastrous Bay of Pigs invasion of 1961, which attempted to emulate the successful ouster of Jacobo Arbenz in Guatemala in 1954, through an invasion which followed similar lines.
Point being, while Mao was Communist while he fought to take power, Castro was never openly Communist. The fight against Batista was heterogeneous, even within Fidel's own guerrilla movement (M-26-7). The Communists only played along after victory was assured, and only became key parts of his government after the Revolution had already come to power in 1959.
In regards why the Cuban Revolution went Communist, the hypothesis of authors like Cuban historian and philosopher María del Pilar Díaz Castañon (Ideología y revolución: Cuba, 1959-1962) is that the fight against the US (defending Cuban sovereignty at the Bay of Pigs), the achievement of long sought nationalist policies (like agrarian reform), and Fidel's success in presenting Communism as being coherent with Cuban values and history, allowed Socialism to fuse with strong Cuban nationalism, and thus pave the way for Fidel's co-opting of an otherwise Social Democratic Revolution.
Sources:
Lars Schoultz: That Infernal Little Cuban Republic:The United States and the Cuban Revolution
Louis Perez Jr.: Cuba: Between Reform and Revolution
Aviva Chomsky: A History of the Cuban Revolution
Jim Rasenberger: The Brilliant Disaster: JFK, Castro, and America's Doomed Invasion of Cuba's Bay of Pigs
Lilian Guerra: Visions of Power in Cuba: Revolution, Redemption, and Resistance, 1959-1971