@rabbitsshadow that doesn't require punishment. Player interaction includes attacking other players. It is fine for those other moments to be rare, it makes you appreciate them all the more when they do happen.
You should have the mindset that you have. Doesn't mean you can't interact, or even try to interact in a peaceful manner when confronted, but you should be ready and expecting that pirates in another crew may well be out to take you out or steal your stuff. We're all pirates out there, after all.
I manage myself with some simple rules, and I'll communicate those in attempted peaceful encounters. You keep your Ship out of Cannon range from mine (keep your broadside away from me), you don't come on my Ship (even if we form an Alliance). Break these rules and I will engage, either trying to kill you (you came on my Ship) or to sink you (you put your Ship in a position where it could be a threat to mine). I might not win the engagement, but it is going to happen at that point.
Is it possible that I make exceptions for any of these personal rules? Yep, on a case by case basis. You let me know you are turning your Ship to reposition (which will cause you to broadside me) in advance and I'll probably allow it (I'll load up to be battle ready just in case you try something). Announce your desire to come on my Ship and why, I might let you up there if you keep your Weapons holstered and accept mine will be drawn the entire time as I keep an eye on you (cause one wrong move and I'm gonna try and take you out).
Along with all that:
Keep an eye on your surroundings, even in the midst of doing other tasks take a beat to check out the horizon all around you. This will reduce the odds of someone sneaking up on you. Look out for more sneaky tactics by scouring for Mermaids and Rowboats.
Don't implicitly trust anyone outside of your own Crew, and even then not if you're in an Open Crew (there are ways to troll in this case, which is why we have the Brig option). Pirates are prone to betrayal if they think they can get the upper hand.
Be firm and back up things you state. If you take my advice actually be ready to at least try and take people out. If you are lenient you are showing weakness, if you show enough weakness you make yourself a target among pirates.
All in all, the pirate code was not broken by what you describe, and Outposts are not safe harbors (the only safe space in Sea of Thieves is on the Ferry once you're already dead - no one can harm you there). Keep your head on a swivel, keep your wits about you, and be more pirate!