Well, in broad strokes, if you think you have a pattern of falling for unavailable people, examine why. There is likely something valuable to be learned from reflecting on that.
However, the heart is a wily beast and not so easily controlled. Unless you only hang out with always available poly people (rarer than the fabled unicorn!) you will come across attractive, awesome people who are unavailable for whatever reason. Maybe they are mono, maybe poly saturated, busy with life or just not interested.
I think you handled the situation with your recent crush beautifully. It didn't turn out how you wanted which is so painful. But you may have made a long lasting connection with this couple. The friend could not reciprocate but I suspect she may reflect back with joy knowing that you, while she was so sick and struggling, still found her lovely and desirable. That is a hell of a gift. And think of what she gave you, honesty and trust and respect for your gift, even though she couldn't accept it. You seem to have learned so much. Yes you could avoid the pain of rejection and loss by avoiding similar situations or people. But maybe you shouldn't. A much harder path with more pain but possibly so much more alive and rewarding!