Usually it all starts with basic concepts that go further and further with years. A mechanical computer employs similar components to a conventional motor, with gears and such pieces. They were capable of calculating maths until a degree of complexity. They are very useful to understand what's all about with computers.
An instruction in a mechanical computer would produce an activity that moves other pieces. After it, the state of the machine changes so other instructions actuate from them producing a result. This result could be a multiplication or a square root.
After mechanical computers, thanks to electricity, to develop digital forms was possible. First with very expensive and unoptimized devices like vacuum tubes, and decades after with the advent of the transistor, the possibilities were constantly increasing.
A today's processor could include billions of transistors, imprinted on silicon using a lithography process. Competition and the search for figures helped in the development of more advanced processors, improving both electric usage and performance. However, these figures are coming to an end due to the intrinsic theoretical limitations. Another form of computers are being tested, those quantum processors that pretend to use four states instead of two, improving the binary standard that is present in the current technology and since the origin of the rational thinking: on and off.
So, on and off could be made in a mechanical device, right? That was the idea of computers.