My guy, you spared those slaves lives of abject torture and misery by sinking that ship. There was nothing immoral about what you did; it arguably would've been even more fucked up to keep them alive as they would have been recaptured and put through all of that all over again. You absolutely did solve the problem explicitly by using force.
Even if it was, you had no way of knowing the developers clearly didn't take into consideration the fact that people would purposefully raid slave ships to save the slaves anyway.
Just because it didn't go as planned doesn't make what you did wrong. What matters is your intent and only your intent. Things don't have to go perfectly or even correctly for force to be justified.
🤦 Why the fuck people feel guilty for using force in such contexts is beyond me.