Digital computers are devices that automatically perform long sequences of calculations.
That a machine can perform arithmetic has long been known; a machine for addition was designed by Blaise Pascal of a type that is still occasionally sold as a plastic device for keeping track of one's grocery bill, and, still many years ago, Leibnitz designed a machine that could multiply as well as adding and subtracting.
However, it was not until after World War I that "adding machines" became able to perform all four basic arithmetic functions without some degree of supervision from their operators. Before World War I, an office adding machine had limitations similar to those of the CURTA, a mechanical calculator for the pocket sold in the 1950s and 1960s, and much admired as a collectable thing of beauty today. That is, to multiply a number by 25, one not only had to turn the crank seven times, but one also had to move the accumulator over to the next position oneself.
Thus, it isn't surprising that Charles Babbage encountered great difficulties in making the Analytical Engine of which he conceived in 1833. But Babbage lived until 1871, and the telegraph, publicly demonstrated in 1844, soon thereafter used repeaters, a type of electrical relay. These could have been used to make a computer without requiring high tolerances of manufacture, and indeed, when the very first computers were built, shortly before the outbreak of World War II, they did use relays as logic elements.
In fact, Torres y Quevedo, known for having built a device from electrical relays that played a Rook vs. King endgame in Chess, wrote a paper which was published in 1920 outlining the design of a computer built from electrical relays. Before that, in 1909, Percy Ludgate proposed an alternative design for a mechanical computer designed on somewhat different priciples from Babbage's Analytical Engine.