The UK will buy up to 7,000 long-range missiles, rockets and drones and build at least six weapons factories in a £6bn push to rearm at a time of growing threats.