Meh, having the same number of code lines (highly dubious) then realizing that you implemented something wrong is just a waste of time for everyone. Why so quickly dismiss the expertese of the people writing (and maintaining) these libraries who in all likelyhood have much higher expertese in that one area of development? Instead, you write an in-house job that takes significantly longer (even if the LOC -may- comparible) then you realize it doesn't work. Your opinions are to bite the bullet and replace using off the shelf, or fight through the crap wasting more time and money.
All the above paragraph of course depends on what you're writing. If you can write the code in a day or two, I'd say its acceptible to eschew known libs'frameworks. If you're writing a very very tiny chunk of an existing library, you may be better served not dealing with the cognitive load and learning curve to introduce the new library. But, you also have to ask yourself if your currently fragile and developing system will ever have its requirements change and if so, will your implementation meet those future demands (Yes slippery slope and all that). Most of the time, built-frameworks were written by many hands for many different projects and they learned to support areas of expansion which are probably most likely to occur in the average project.
On the flip side, there are times where libraries and frameworks should be looked at skeptically, and it usually revolves around active engagement. If there isn't much or any active development on a product, its either reached its peak goal (something like log4j perhapse is a good example) vs. some dude's web templating engine that may have been brilliant when it was written 5 years ago, but has long been abandoned. It may end up being the perfect fit for your project and team, but it means having to learn and support that potentially unknown blob of functionality. That's when a library/framework can become a boat anchor, especially when it becomes a core function of your system.
From personal experience, I started a junior dev job on a several million line project where we were so highly coupled to a vendor's library that when vendor decided to stop supporting it, we were left dealing with the countless defects that came from it every time we needed to use it differently (sadly more often than anyone wanted). Lots of drama, blah blah, but by the time I left the company, little was done to fix it, which isn't surprising since they allowed the library in to begin with.