Look, when Ed leaves with Jack it isn't Ed choosing Jack over Stede as the better partner/love interest. This is what Stede thinks is happening. Stede hasn't even entirely admitted to himself at this point that his investment in Ed is romantic, but he does treat it as a breakup, he sees Jack as a rival for Ed's attention/love, so from Stede's perspective, yes, Ed is leaving him for Jack.
Stede thinks he is in the romance novel plot and has to compete with his love interest's ex for his affections.
This is also what Jack is intending to make Stede feel.
Jack is playing a con. He is actively working towards Stede coming to the conclusion that Love Triangle Business is happening, but Jack's motivation isn't winning back Ed as a boyfriend from Stede. I don't think Jack does boyfriends. Jack does dalliances. He would probably agree with Lucius's "we don't own each other". And this would apply if Jack happened to randomly come across the Revenge and decide to fuck with Ed's new crush for kicks and giggles (which is what Anne and Mary do when in that situation!). But Jack doesn't come across the Revenge by accident. He is on a mission, given to him by Izzy. We don't know if Jack gets paid for it or if he does it because he's worried about Ed and doesn't want the Navy to get him, or some combination of both, but Jack is the only one in this equation who actually knows what is happening, and what is happening is a plan to drive a wedge between Ed and Stede to make Ed leave the Revenge so he's out of the picture when the Navy shows up.
But neither of this is what's going on from Ed's perspective. (This entire episode is a masterpiece in the "characters completely misunderstanding each other and what's going on" trope.) Ed doesn't really figure that he's been cast as the pivotal point of a love triangle. Ed isn't spending the episode trying to choose the better boyfriend candidate and then leaving with him.
Ed is busy having a personal identity crisis.
This crisis has been ongoing for a while when Jack shows up. With Izzy's pressure to pirate a certain way gone, Ed is freer to explore what Ed wants to do now and how he wants to live and who he wants to be. He is tired of the traditional pirate life, he wants to try something different. He also isn't ready to fully do a hard cut. He just figured out Stede might return his feelings during the treasure hunt. They just decided to co-captain. A lot of things are changing for Ed.
And then comes by a very old pal. Jack and Ed have history, they used to sail together, they survived their difficult youth under a cruel captain together. Jack represents a different type of pirate life than Izzy. Jack is fun. (Everyone but Stede thinks Jack is fun, and that's in no small parts because Jack is actively working towards making Stede uncomfortable but everyone else have fun and take Jack's side - this works on everyone in the crew including Ed!)
From the beginning on, Ed is struggling to make Stede and Jack get along and like each other. He's trying to somehow combine his old life and his new life because he doesn't want to choose between one of them. He wants to have the best of both worlds. He wants his old friend and his new friend/his ex and his crush to be friends and get along. He wants to keep what was fun about traditional piracy (as represented by Jack) but also move on to Stede's new brand of doing things. He wants fancy breakfasts, and then has to realise that Jack pours alcohol into his teacup. He wants to play coconut war like the old times, but has to realise Stede hates the idea. A big part of this episode, from Ed's perspective, is about trying to reconcile these two worlds and failing.
Ed's main problem, through both seasons, is that he doesn't really know who he is or who he wants to be. He struggles massively with self-worth and self image. He views himself as an unlovable monster and spends his entire life bending over backwards and wearing masks to cater to what he thinks other people want him to be. He plays up Blackbeard for Izzy, Blackie for Jack, and he isn't sure if who he is being with Stede is actually Ed or not. Ed thinks nobody can possibly like him, so he constantly tries to perform to whatever expectation his direct peers have of him.
Next to this main crisis, Ed is having another secondary crisis called "fuck I'm in love with this guy" and "does my crush like me back". This secondary crisis is heavily influenced by the first, because Ed thinks he is a terrible unlovable person, remember, so "does this guy who I think is the bee's knees return my feelings" becomes a lot more fraud than it would be for a person with a modicum of self-esteem.
Ed, who struggles with "who/what am I as a person", sees Jack as a person who is similar to Ed. They have a lot in common. They share a lot of backstory. They are both pirate captains. They used to do the same things. Ed always played Yardies and Whippies and Turtle Vs Crab, because really that's just pirate culture. The main difference between Jack and Ed is that at some point Ed outgrew this life, and Jack didn't. But Ed, who is bad at recognising himself as a person and to define his identity, is only sorta vaguely aware of that. In Ed's perception, him and Jack are very much alike.
So when Stede, Ed's new friend and crush who he already thinks is too good for someone like Ed, starts rejecting Jack and Jack's behaviour, and says things like "I don't like who you are around this guy", what Ed hears is "I don't like who you are". Ed hears Stede thinks Jack is a bad person, and because in Ed's head a) he and Jack are the same and b) Ed is a bad person anyway, Ed hears "you are a bad person".
"You were always going to realise what I am", says Ed, as he is leaving with Jack after Stede tells Jack to leave the ship. Note the dehumanising "what" instead of "who" Ed used for himself. Ed, who thinks he sucks and is an unlovable monster, thinks this is the other shoe dropping, and he's been waiting for it to drop all along, because someone great like Stede isn't for a guy like Ed. Stede was always going to see what Ed is.
Ed's leaving the Revenge/Stede is 100% down to Ed's abysmal self-worth. It's a self-perception born from childhood trauma that fucks Ed over several times during the show (and ultimately leads to his suicide attempt).
Ed is so busy having All That going on that he mostly fails to notice that Jack is playing him, or what exactly happens between Jack and Stede, that Stede perceives Jack as a romantic rival for Ed's attention/affection or that Stede too struggles with self-worth and that Jack is hitting him where it hurts all the time. Ed's headspace in this episode isn't "oh, two sexy guys I like, which one should I choose to be with". It isn't even "oh my old pal is being a real dick to my new friend who is feeling really insecure here". Ed's headspace is "I'm a terrible person and Stede is seeing it now and Jack wants me to do more pirate party stuff but Stede hates that so now they both hate me and I probably deserve that because I'm a monster".
Ed leaves for Jack as much as Stede an episode later leaves for Mary. It's the exact same situation. For Stede, his own trauma and self-worth issues show up in the form of Chauncey Badminton, telling him he is a monster and ruins beautiful things, and Stede's reaction is to agree because he already thinks that of himself, so he takes his horrible ruinous monster self away from beautiful things (Ed) and back to where it belongs (to a miserable life he was hoping to leave behind). And for Ed, no Chauncey Badminton is required, because he's already constantly thinking these things about himself anyway. From Ed's perspective, Stede tell him he is a bad person (just as Jack), so Ed agrees and takes his horrible self away from beautiful things he doesn't deserve (Stede) to a miserable life he was going to leave behind.
Neither Jack nor Mary actually feature into the leaving much. Neither situation is "leaving the new guy for the ex". They're both situations of "I have a fuckload of trauma and self-hatred and it destroys my actually pretty nice new relationship".
And this is very interesting as a parallel. It doesn't even end there! When Stede returns, and Ed hears where he went, Ed too goes to "you left me for Mary". Same as Stede went to "you left me for Jack". And neither of it is actually what was happening!
Stede doesn't leave Ed for Mary, and Ed doesn't leave Stede for Jack. They both decide, driven by very similar trauma, to leave because surely the other one is going to be better off without them.