Modern manufacturing accounts for this. Any brand worth their salt expect a certain yield to cover bad parts, assembly line faults, etc. There are often multiple QA test stages to account for this. Brands/manufacturers also expect a certain number of RMAs, and set up an RMA process. A good RMA processes can reveal pathological issues (like falsified QA reporting), so good brands/manufacturers will be flexible with their customers as long as they're not being defrauded.
Part of the problem is the big contract manufacturers (like Foxconn) are impossible to compete with on precision/cost.
In a past life, we moved a product from German manufacturing to China, as the German tooling wasn't fine enough to hit our (admittedly insane) tolerances. Whether or not the China MFG lied, they signed the contract and produced the parts. Though, we had to spend a lot of resources on additional testing rigs to weed out the tolerance misses/assembly line faults/bad parts over and beyond what the MFG caught.
Not to mention that exporting stuff from China even 10 years ago was a lesson in geopolitics. Not for the faint of heart. We ended up having Hewlett-Packard (who we were a very large customer of, and white-label resellers for them) export our first thousand or so units in HP boxes. Like night and day.
The overall competitive advantage is hard to capture. Time, money, ethics, work ethic, efficiency. Having an entire country's incentives aligned with extracting a cut of almost all consumer electronics in the world is hard to challenge.
I wonder how the next 15 years will look now that the part seems to be over.