What was going on here?

So I was friends with a girl recently and after a few months I developed feelings for her. All this time, she was involved with another guy who she had met a few years before meeting me. They were friends for a couple of years because she had a different boyfriend when they first met, but eventually got involved with each other once she broke up with that boyfriend. However, there was no label to their situation. I guess they were "talking" or "hooking up" or whatever. But no official label. Anyway, my friend would tell me that I'm cute and attractive sometimes, so of course I got the feeling that she was into me. Eventually once I started to like her, she said she already liked the other guy she was involved with. This is where I'm still confused. The fact that they weren't actually official makes me think that she believed he's better than me? Or maybe she just actually really liked him? What also bothers me about this is that she would tell me how the guy would hang out with his ex sometimes and it would make her upset. And yet she still liked him and wanted to stay with him. This made me think, "why would she want to be with someone like this?" "Am I that undesirable?" "But she's said im attractive?" I know this is a lot, but I'm just very confused.

What was going on here?
Post Opinion