The destination is chosen to be friendly to the trader. (Or to be Pirate.) You are friendly to the trader's nation, otherwise the tavern keeper wouldn't have made the contact in the first place. When you get to the destination, you'll be under a friendly flag, or you'll be fighting the local fort. You might not be personally friendly with the destination. (Example: towards the end of "Ardent", you probably have both English and Spanish LoM, so your served nation is "Personal". You're still not friendly to either Portugal or Holland. Holland is allied to Spain and Portugal is neutral.) If the enemy ship is set to be hostile to your served nation, it could therefore belong to the nation whose port you're trying to enter. If you set a flag hostile to it, the local fort will attack you, and so will the merchant if you didn't previously tell him you'll be using false flags. If you don't set a flag hostile to it, you're either firing at a friendly ship or you're not defending yourself at all.