The libraries are there for avoiding repetition. It is useful on its own without other benefits like implicit/explicit boundaries, readability by humans etc. If all lego(base unit software) pieces were unique shaped it might fit your requirements more efficiently but the cost of building those unique shaped legos explodes with the size of the lego piece required.
LLMs compress the known shapes well and fit them to solve for a problem but they are still not good enough to build from scratch a large new lego piece which fits a full problem perfectly. And such a large lego piece might not be the most efficient solution either and might be difficult to prove so.