I am not a barrel maker, but I've interviewed one and shot a lot of premium match-grade barrels. If you pick out the top ten barrel makers for premium match barrels in the US (ie, custom barrels), they churn out barrel after barrel capable of winning matches. In this sense, the technology and techniques required to make very accurate barrels is known and repeatable. There are a whole host of things that these guys do to make an accurate barrel, including: using the right steel, doing the machining operations in the right order, cutting the right amount off at the right time, using good tooling, making sure twist rate is consistent, making sure internal dimensions are spot on, and hand-lapping the surface to make sure it's just right.
Also critically important is the operation of cutting the chamber. If this is not done true or it's screwed up in some other way (chatter etc), the chamber will harm accuracy.
In a factory rifle, many of those details may be bypassed because of a higher production rate. If you have a factory rifle that doesn't shoot, you may have to go back and attempt to fix any of those things that may be wrong: true threads, square shoulders and receiver face, no defects in chamber, and properly polished bore.