Enigma machines used interchangeable rotors that could be placed in different orientations to obtain different substitution patterns. More significantly, the rotors rotated after each character was encoded, changing the substitution pattern and making the code very difficult to break. For examples, let's pretend there are only six letters in the alphabet, and we have the three rotors below.
In the first rotor, if an 'E' is entered, a 'C' comes out. If an 'A' comes in, an 'F' comes out. Whatever comes out of the first rotor, goes into the second rotor. Whatever comes out of the second rotor, goes into the third rotor. For our simple model, whatever comes out of the third rotor is the encrypted character. For example, to encrypt a 'D'...
At this point, it may seem that this is just a substitution cypher, just an unnecessarily complex one. Well, after encrypting this 'D', Rotor 3 is rotated one slot (in the below picture, notice how in the third rotor, 'A' no longer maps to 'C' - instead, it now maps to 'E', which is the letter 'B' used to map to. In other words, each letter in the right column has moved up one spot). So, when we encrypt 'D' again, we get a different encrypted character.
OK, fine, you say, so it's not a substitution cypher. But, because the rotor must eventually rotate all the way around again, it is just a Vigenere cypher with a key length of 6, and those are still vulnerable to a statistical attack. So here's the second twist... when that third rotor is rotating around to return to its original position (after the encryption of the 6th character), the second rotor rotates once as well, again changing the encryption. When the second rotor rotates all the way around, the first rotor clicks once, as well. So, the rotors don't return to their original position until you have typed 6^3 characters (26^3 if we're using a full alphabet). Essentially, this message has the same statistical properties as a one-time pad.
But how would this be decrypted? Well, each day the Germans had a secret key, consisting of how to put the rotors in the machine. If you had them in the machine in the proper places, you merely had to run the encryption backwards, allowing the rotors to click after each letter as if encrypting, and you would get the message back out.
There was more to the Enigma than just the rotors, though they were the main innovation. There was also a plugboard, with six wires, which performed a simple pairwise substitution on 12 of the letters first.
In the above picture, we've added a plugboard, in which if 'B' is entered, it is substituted with 'D', before being sent on to the first rotor. Similarly, if 'D' is entered, it will be replaced with 'B'. If 'A' is entered, it leaves the plugboard as 'A', because no wire has been placed in its plug. The below picture illustrates how to encrypt a 'D' with these settings.
This plugboard massively increased the number of possible settings for the Enigma, making Alan Turing's job much, much more difficult.
Finally, there was a reflector. The reflector was similar to the plugboard, in that letters were combined pairwise, but differed in that every letter has a partner. Additionally, once the reflector output a letter, that letter was fed back through the rotors and plugboard in reverse.
And here's a picture of a full Enigma encryption:
Here, the D is entered, the plugboard converts it to a B, which goes through the rotors and comes out as an F. At this point, it enters the reflector, where it comes out as a B, due to the fact that F is paired with B in the reflector. This letter then moves backwards through the rotors, emerging from the rotors as a C. Because C is not paired with anything on the plugboard, the C enters and leaves the plugboard without being altered. So, the D is encrypted as a C. And then the third rotor would rotate.