The Nazis had physical code books they would distribute. They would determine the Enigma settings for the day. Then using those settings, each message would start with a message key setting the starting rotor settings for the rest of the message. These were useful as cribs for breaking out messages since all messages the Nazis sent for a day started using the same key.
The most difficult Enigma codes to break were used by the German navy. They were highly disciplined about their use of keys, their Enigma machines had an extra rotor, and they didn't produce nearly as many messages per day as the air force or the army did. And their code books used water-soluble ink so if they were abandoning ship all someone needed to do was chuck the code book overboard, which is embarrassing because no one did that when the British captured U-110 on May 9, 1941. And because they couldn't distribute new code books to the navy without recalling the entire fleet to port, the Germans had to use compromised codes for the rest of the month, giving the British much insight into how they operated.
Enigma messages were basically broken with brute force. The British had electromechanical devices called "Bombes", which were basically devices that would tick through every permutation of Enigma key until they came up with plaintext. These were assisted by the cryptanalysts who would deduce possible plaintext for a given cyphertext, called cribs. These cribs would substantially reduce the number of keys to search if they were correct. Contrary to popular belief, the British did not invent the first electronic computer to break Enigma, but a different, more complex cypher used by the German high-command.