Computers aren't magic. Underneath your fingertips right now are wires and logic gates. Switches. A 1 becomes a 0; two 1s become a 1; a 1 and a 0 become a 0; a 1 and a 0 become a 1; two 0s become a 1. Simply, different sorts of gates take on/off signals or pairs of on/off signals and emit more on/off signals in response. The most basic idea of logical computation and binary arithmetic goes back to Leibniz in 1705.
You don't need electricity to implement binary operations, though it certainly helps. All you really need is a way to ensure that somehow the binary inputs to the gates below (the As and Bs) result in the correct binary output (the X). When you have that, you have the materials for a computer and can theoretically do anything.
For those that remain doubtful, Github user lapinozz is here to the rescue with a 4-bit computer constructed out of cardboard and marbles. It's pretty amazing:
Here's an AND gate below. As you can see in the chart above, an AND gate is only supposed to output a 1 (a marble) if there are two 1 inputs. Otherwise, it outputs a 0 (no marble).
In a computer, logic gates are combined into constructs known as half-adders and full-adders. This is how logic becomes arithmetic. A half-adder looks like this:
So, the cardboard computer is actually a combination of adders, as below.
"I built it with my little sisters for a science activity, it can add numbers from 0 to 15 for a maximum computable number of 30," lapinozz writes. "We made it from scratch and at the time I didn’t see any of the various kind of calculator that have been made using Lego, wood and other, so it’s a completely new model!"
from Someone Built a Working Four-Bit Computer Out of Cardboard and Marbles