The factory will have to shut down if under siege. They'll only have whatever supplies are on hand, enough to make a few more droids, but not very many. And the Sith don't need to force their way into the factory, just bomb the entrance and cave in the base on top of it.
With the invasion the HK's are programmed to kill Jedi, and the defenses of the factory are programmed to also kill Jedi. The Sith would be slaughtered. the HK's could also use flamethrowers and carbonite attacks to kill the Sith. Or they could be suicide bombers and run with bombs about to go. Droids can be programmed to do anything.
EDIT: with the factory, new droids are constantly being produced. The numbers argument is sort of, not completely, but sort of invalid.