Tidslinjen för händelserna skiljer sig från hur den visas i showen, som spekuleras i detta svar på Movies SE :
Prince Trystane was assassinated while on a ship that was docked at King's Landing several weeks after the assassination of Prince Doran.
The episode doesn't really make this clear, because events in Game of Thrones can be quite apart in time, despite being shown in a linear fashion.
The events in Dorne do appear to happen directly after the last episode of Season 5. However since Prince Trystane was on a ship that went to King's Landing, some time must have passed. How much time? I'm no sailor but the distance between the two looks quite big and I would guess at least several weeks.
Presumably Obara and Nymeria Sand also sailed to King's Landing just behind Trystane Martell.
Things are being shown happening at very different times.
Trystane kvar på fartyget är troligtvis orsakat av möjligheten till vedergällning från Lannisters.
Av intresse är Jaime Lannisters brev till prins Doran Martell, som är tillgängligt på webbplatsen Making Game of Thrones :
Han skriver:
[...] Your son cannot stay in King's Landing [...] am sending him back on the same ship.