Why boundaries if our feelings never come from other people’s actions?

If we consider that our happiness, wellbeing and all other feelings are independent of others and solely dependent on our thoughts, why do we need boundaries?

How do you decide whether you need a boundary to remove yourself from someone or whatever else you’d so versus working on managing your thoughts so that what they do doesn’t really matter to you?