Electrum, when using the 12 word seed (aka "wallet words") to generate a wallet, creates what is known as a Hierarchical Deterministic (or "HD") wallet. Essentially it uses mathematical "magic" to reproduce the same addresses and keys from a given starting point.
I like to try and explain it like a very very very large number of hallways, that all have a very very very large number of doors. Behind each numbered door is a room containing a collection of addresses/keys. You basically go to the hallway that is set based on the "Derivation Path" that your wallet uses. The 12 word seed tells you which door to go to in the hallway. So, if your seed decoded to #12, you'd go to door number 12 and behind that door is the room with your collection of addresses and keys.
So, when you come to restore, the wallet picks the hallway based on the derivation path and then your seed puts you at the same door in the hallway as last time and you get the same addresses/keys
The "derivation path" (for picking the hallway) is a specific value that an HD wallet uses, some use "standard" or common values with other wallets, so you can take a seed from one wallet and use it in another and you end up in the same hallway at the same door. Some wallets use unique derivation paths, so they're incompatible with other wallets. This means that even though you can put the same seed in and it still says start at Door #12, because you are in a different hallway, you end up at a different room and get different addresses. This is one little "gotcha" that a lot of people overlook and causes issues if they try and use their Electrum seed in another wallet like MultiBit HD (or vice versa).
As for the coded/decoded part... Basically, addresses and keys are really just very very VERY big numbers... the jumble of letters/numbers that you see is just a slightly more compact and user friendly way of recording them (with some checksum functionality thrown in to help catch typos)... The method for converting from the underlying number to the letters/numbers is well publicised and repeatable... It may be a bit more complicated, but like simple maths, given the same input, the conversion/generation process will generate the same output. ie. 2+2=4 and will always equal 4
Hopefully, that helps explain some of the "magic"