This question already has an answer here:
I read a story in a collection of short sci fi stories which I can no longer remember the name of.
In the story mankind built large, self-repairing, sentient factories that made war machines and supplies for them (they were fighting other humans on the same planet). The war was so devastating that the command structure of the humans was wiped out, and though the war machines won the war, no-one had the control codes to turn off the factories, so they kept building more and more useless junk for the humans.
The main characters are trying to convince the ruling AI that they don't want more junk, but the AI doesn't care, so they trick it into attacking a different factory, which causes a factory war and the story ends with the factories launching seed factories into outer space to take over the universe.
What is the name of this story?