Bottom line is your up sh-- creek without a paddle. Whether they do it consciously or sub consciously women like the one you described value attention more then any other thing. Any attempt at trying to rationalize her actions without attention as the main variable will only make you more confused.
This girl has low self esteem, she probably hides it well but deep down she doesn't like herself. As a result she craves attention constantly as a way to help her manage her low self image. She gave you the impression that she likes you by probably throwing in the occasional flirt and spending so much time with you. The reason she did so was to keep your interest in her sparked and keep the attention meter flowing.
What really makes the hole thing even more confusing is the thing that she craves the most is being offered up on a big silver platter by you, yet she passes. The reason is not because she doesn't love your attention, its because she knows she can have it whenever she wants it.
As to why she is attracted to a-holes it is also pretty confusing, but then again what about women isn't? It basically revolves around two main things, first women love project men, especially women with low self esteem. They think they can change bad men to good men, good men to better men... etc. Simply put, guys that treat them badly are the biggest projects of all so naturally they appeal to them.
For point number two we revert back to the attention thing again. A-hole type guys give this girl a constant flow of attention, its just not of the positive variety. What else screams look at me more then a girl being able to constantly talk about how bad her boyfriend is. How he calls her names, treats her like dirt, and has left her emotionally destroyed. Everybody else simply wonders why she wont break up with him, but why would she? He is giving her exactly what she wants.