The first Enigma machines were meant for purely commercial use, sending coded telegrams which your business rivals could not read, then the German military adopted them and made them far more complex.
The Polish Secret Service did a lot of the ground work in breaking their encryption (details of the machine were passed to them by a German officer for money) which they then passed on to the British and French just before the war, miraculously the Germans never found out about this, the boffins at Bletchley Park, including Turing developed even better ways of cracking the cipher, this worked out so good that towards the end of the war they were decrypting messages before the German high command did.
The only exception to this were the u-boat machines which had four rotors instead of three which made them much, much harder to crack, but even these succumbed in the end, the one fault that the Enigma machines had was they never encrypted a letter as itself, you could keep pressing the letter E forever and it would never be encrypted as E, it also helped that it's human operators could be lazy in the way that used it and would use the same opening phrase over and over.
An even harder cipher was developed called Lorenz based on teletype protocols, Alan Turing helped to developed one of the first programmable computers to decipher Lorenz which was then built by telecom engineer Tommy Flowers, just another unsung hero in the war.
The machine was code named Colossus and it worked with thousands of thermonic valves, the room it was housed in would get really warm, so it was not unusual to see the personal laundry (underwear) of the WRENS who operated it hanging up to dry in the heat, sadly after the war Colossus was scrapped with just a few small elements surviving.
And yes a certain amount of Enigma machines were passed on to what would become commonwealth countries for their use, so we could keep an open ear on them.
Other unsung heroes in this saga were the wireless interception service, some would have been army but a lot of them in Britain were volunteer civilian radio hams.
Also Bletchley did a lot of work along side the Americans breaking the Japanese codes and ciphers, amazing work by a great bunch of people!
P.S. Admiral Donitz head of the U-Boat arm of the German Navy realized that the Enigma code was being broken, but he always thought this was due to a highly placed spy somewhere in the navy ranks, he always thought that the machine itself was totally invulnerable.