Many builders actually buy construction defect insurance on the home so if something comes up during the warranty period, they are covered to make the repair. In some cases, a whole tract or condo development may experience construction defects. When that occurs if there is a Home Owners Association, it is not unusual for the HOA to retain an attorney to represent all homeowners to get construction defects fixed.
Years ago, this happened for this Blogger. Our home had galvanized pipe that apparently was defective. Many homes began to spring leaks. So our HOA represented all 700 homes in the tract in order to get the pipes repaired. It took a year or more to settle the case; but eventually all the homes in the tract were re-plumbed with copper pipes. Actually, it really was not a horrible experience. The contractor was able to make a few strategic holes in the walls, which were ultimately repaired to put in all new pipes.
In any case, if you purchase a new home, hopefully you will not experience any construction defects; but if you do, just know that the builder must repair anything deemed a construction defect during the warranty period.