Thanks for playing! You're definitely right, the moment you start attacking the settlement the rebels should no longer be hostile towards you & targeting should update to focus on the settlement/ treat them as allies. I'll sort this in the next minor patch. Thanks for the feedback!
Edit - Fixed in latest build