The alliance mechanic is perfect, IMO, because it does exactly what it's intended to do - it facilitates social interactions - both good and bad. Like was said, it's people that are the issue, but even then they're still playing the game how they want, and perfectly within the rules of the game.
A stable alliance provides huge long-term gains for both parties, but due to how easy it is to trick and betray (not to mention how much more fun it can seem to many a pirate), it lures greedy, short-sighted pirates into a get-rich-quick scheme with immediate short-term gains. Perhaps they don't have time to wait (or don't want to) for you to get more, so they figure that stealing from you is a good way to maximize their profit margins?
Betrayal is not without risks though - it's a high-risk, high-reward scenario; you essentially get double, or nothing. That's why they'll pretend to be your friend and stab you in the back. Once they do though, that's it - no more potential gain for them.
A good rule of thumb is this: trust NOBODY fully except for your own crew.
Always have your head on a swivel. If you're in an alliance and about to turn in, check to see if other allies are nearby - if they are, don't turn in. If they are true allies, they'll respect your space. Use your map table to spy on them, as they are surely already doing with you, since the alliance mechanics allows for it. If something seems fishy or too good to be true, it probably is.
Learn your allies names too - doing so will help prevent 3rd party infiltrators from destabilizing a perfectly good alliance, if you have 1.
I hate to say it, but your ignorance caused your own defeat, not the mechanics of the game, so don't ask a game to change what it is at its core to accommodate your shortcomings and inability to play the game effectively. You sink or swim; you got sunk - now start swimming.