So, all he had to do was stumble across it and perhaps modify its original function (mere observation and cataloging perhaps) to what he needed it to do; travel back in time from 2008. All questionable things like how he would have even known where to go and how/when the gate was originally transported aside, he managed to travel to 1939 and get aboard the ship and alter the timeline.
Presumably this is also when he rebuilt the machine, although I'm not sure why since it seems like everything went as planned and he would have needed those 70 years to get to the position he was in to attack/enslave Earth. Maybe it was a backup plan for when things didn't turn out the way he wanted them to and he could redo it.
Or, what I think is the case, the device wasn't built by Ba'al but the Ancients, waaaay before 1939 and thus would still exist in the altered timeline.
Either way, Carter, Daniel and Mitchell managed to travel to the same alternate timeline and did their thing, ending with Mitchell's trip back to the past (in a timeline different from the original and the altered one, but presumably resembling the original one closest).
Then, in 1939, Mitchell is on the ship awaiting Ba'al's arrival and kills him. The timeline unfolds as it should have now that Ba'al isn't there to alter it and we fast forward to 2008 where the extraction ceremony goes through successfully.
However, with the original Ba'al (who according to some built the machine) killed in 1939 he never managed to build the machine again in the current timeline, so at the end of the movie we're in a different altered timeline that closely resembles the original one (only differences are presumably an extra Mitchell in the past, dead original Ba'al in 1939 and a successful extraction ceremony) but no machine to travel through time waiting to be discovered again...
Unless it wasn't built by Ba'al and earlier than 1939, of course.