1929 the Poles knew about the commercial Enigma and hired three mathematicians for code breaking. The most famous was Marjan Rejewski.
It is not quite clear how the Poles got all details about the military Enigma. Different stories are told. They collected a lot of German messages and have been supported by the French secrete service with copies of Enigma training handbooks got by espionage. With all this information they have been able to rebuild an Enigma until 1933. The correct rotor wiring was found by help of mathematical equations (Gleichung).
The Poles also found out, that the double coded message key at the beginning of each message sometimes leads to identical letters, called "females" (.e.g ABCABC enciphers to PSTPWA, letter 1 and 3 is supposed to be the same letter). This occurred on average every 25 messages.
They developed different devices and methods to find the message keys:
Zygalski, one of the mathematicians, used perforated paper sheets and arranged them on an illuminated table to reveal possible starting states.
The "Bomba" was a mechanical device simulating the 26*26*26 positions of the 3 Enigma rotors. 6 "Bomba's" were necessary for the 6 possible wheel orders (3 wheels until 1939).
Over the years, the Germans did modifications on the messages and the machine itself. They added 2 additional wheels, used more Sockets, the twice given encoded message key was given up in 1940, the wheel order was changed daily (starting from 1937, not only every 3 months). After these changes the Poles didn't have enough money and resources to built 60 new Bombas which became necessary to break the modified Enigma.
In 1939 the Polish mathematicians moved to France, at least they gave all their knowledge and material to the British.
Thanks for correcting me, Milhous.