Wikipedia describes the selection process as "Thirty members of the Great Council, chosen by lot, were reduced by lot to nine; the nine chose forty and the forty were reduced by lot to twelve, who chose twenty-five. The twenty-five were reduced by lot to nine, and the nine elected forty-five. These forty-five were once more reduced by lot to eleven, and the eleven finally chose the forty-one who elected the doge.".
Was there a reason these specific procedures came about? Like why not just have the first 30 chosen by lot choose the doge? It seems strange that there are multiple steps of reduction and increase in the number of people. Especially the case at the start where a lot is used twice in a row (30 by lot reduced to 9 by lot). Why not just select 9 by lot and skip the step with 30?
Were steps added over time, or was the system implemented all in one go? If it changed over time, what caused the need for the changes?
The excessively convoluted mechanism for selection of the Doge of Venice is a consequence of the Venetian's understanding of state and sovereignty, as well as a maniacal desire to avoid conflict, all exacerbated by the fact that these two things remained largely unchanged in the Republic's long history.
The system Wikipedia recounts dates to the mid 13th century. As you indeed have imagined, the Venetians did not initially chose their leaders this way. It is the consequence of centuries of factionalism and negotiation; indeed in the first four centuries of Venice's history, revolt and upheaval were the threats used to ensure the Doge did not spark unnecessary disputes. The complex system of electors and ballots was conceived as an a-priori solution ensuring that the man chosen as Doge was a leader who would not cause a revolt by favoring one faction over another, and most importantly, not put the Republic's life at risk with his own dynastic ambitions.
The historian Norwich, whose History of Venice is probably still the most accessible gateway into Venetian history (as it was for me), attributes this initiative to Venice's prosperity. In the 13th century, the old venetian political dynasties were flanked by an increasing number of newer dynasties, rich thanks to trade and shrewd investments. This led the Venetians to undertake a number of initiatives in the interest of preserving both the Republic and its social order.
The elaboration of the convoluted election system follows an initiative by Doge Giacomo (or Jacopo) Tiepolo, who undertook to standardize and codify Venice's laws, which until then were a mixture of customary justice, roman law, and guild codes. We do not know if he was reacting to concerns tied to the Venetian state's power, but given the Venetian's near-pathological attention to the preservation of the Republic, they might very well have: Giacomo Tiepolo's predecessor, Pietro Ziani, was absurdly wealthy and well-connected, having even married a Sicilian princess (even though he was far too old and tired to ever pose a threat to the republic) and in turn Doge Pietro Ziani's predecessor, Enrico Dandolo, might have been retrospectively been judged to have acted with alarming efficiently and success (what if he had decided to proclaim himself King in Venice upon his triumphant return from sacking Constantinople?). Of course, neither had actually taken action against the Republic or its institutions, but evidently they didn't have to if these concerns indeed existed.
We do not know if the mid-13th century atmosphere in Venice was tense. Records of street brawls between rival dynasty members and new sumptuary laws are hardly the armed mobs that unrest had generated in previous centuries. But in Doge's election of 1268, the Venetians nonetheless decided that the convoluted system of ballots you described was the best way to mollify their concerns and choose a Doge who was impartial and did not carry dynastic ambitions.
Unlike their descendants, the early Venetians, living in sparse communities on the islands and sandbars of the northeastern Italian lagoons, probably selected their leaders in rambunctious public gatherings that we don't know a whole lot about (order might have been kept by the local clergy). We don't even really know how, or even why, they chose to democratically elect their leaders (although there are a few very good educated guesses, mostly having to do with needing to pick someone tasked with appointing judges once the Exarch in Ravenna stopped doing it). What we do know is that people elevated to leadership positions were already prominent members of the community, with extensive networks of friends and family to rely on in order to govern, and the involvement of adult children (sometimes even proclaimed co-rulers) could mobilize panicked rivals to depose a Doge by means of violent revolt; and revolts could also materialize when family clans, acting in self-interest determined by continuously shifting networks of association, took advantage of moments of vulnerability to depose a Doge they disliked or disagreed with.
What legitimized these revolts was always the promise of a new meeting of the Venetians, called Arengo, where a new leading citizen would be proclaimed Doge. The ordeal was made simpler by the fact that we are, at this point, in the period before the turn of the 11th century, and the apparatus of government was fundamentally nonexistent: the Arengo, and not a convoluted system of ballots, is what legitimized not only the Doge's power but any sort of political power. In fact, the Arengo could also be called to pair a particularly elderly Doge with a more vigorous partner in times of crisis (like leading sweeps against pirates, or fending off ambitious Frankish Emperors).
The road was a long one between the simple system of the early Venetians and the complex system of ballots you asked about. Its description follows in the reply to this comment.