What exactly does a key do?
Picking up what has been said in the comments:

to simplify: symmetric ciphers are like mathematical operations with 2 operands and 1 result. There is The plaintext message $m$ and $k$ as the key and they result in the ciphertext $c$. In your example, the algorithm can be cut down to a addition and modulo:

$c = (m + k) \mod k_{max}$

And of course there is a reverse algorithm (or more simply operation) that will turn $c$ into $m$ again:

$m = \begin{cases} c - k,&amp; \text{if } c\geq k\\ c + k_{max} - k,&amp; \text{otherwise} \end{cases}$

To sum it up: The way of calculation (the algorithm) never changes. Instead, the parameter(s) to it, the key, are different.



In the computer world these operations are much more complex and involve operations that are easy to compute in the binary system (e.g. XOR or bit-shiftig) that are rather complex to express mathematically.