For tournaments you'll want about 20 buy-ins. This varies though.
The more players, the longer you'll go before a big win, which means your bankroll needs to be bigger to compensate for those inevitable dry spells. So MTT's will require a bigger bankroll.
Yatta yatta yatta...
Your realy problem seems to be overplaying. You overextend your bankroll, and if you're out early/middle so often then you're probably overplaying your
hands.
As far as managing the bankroll part, I think you need to set yourself up with a system.
When I moved up in ring games I set goals for myself.
At $2NL I took $20 of my winnings and designated that "move up money." The rule I made for myself was that I could play at a higher limit with that, but if I lost it I'd have to move back down and play $2NL again until I had $25 profit. Then I could take $20 of that and play at a higher limit until I lost it, in which case I'd move back down to $2NL until I made $30 ($5 more than last time). Then I'd take $20 to the higher limit again.
So I would keep making a profit even if I yo-yo'd in limits.
It's a system that worked for me because I hated $2NL. It kept me from making "oh what the heck, it's only $.10" moves because did *not* want to move back down to $2NL. So suddenly, that $.10 wasn't "juat $.10 that I can win back later or redeposit an replenish" but it became "one step closer to that dreaded $2NL."