When you write a story with a lot of political intrigues, you need to plan out how the complex web of alliances and betrayals will shape out. Sometimes, though, you happen to have a character who would be much better off siding with group B than group A, but still chooses group A.
What are the considerations you need to make that would justify certain characters siding with the risky faction? How do you make that choice believable 100% of the time? Is there some kind of technique, or do you have some useful insights on this?