Why do I have such a hard time keeping friends?

Everytime I make a new friend, it never lasts. I had a best friend that I was super close to that just stopped talking to me one day after he moved out of the clear blue. I reached out, and he has ignored me since but stayed active on his social media and has kept me as a friend on there. I made another friend. She was a nice girl at first. Then, she started bringing me down all the time by calling me names. Everyone told me as soon as she started calling me names to stop being friends with her because everyone saw how horrible she started to treat me, but I didn't listen. She would give me the cold shoulder everytime I brought my husband, who was my boyfriend at the time, around her. After her dad died, she started doing drugs and became a prostitute. I tried to help her out of that lifestyle, and then she tried to lure me to meet her pimp and make me get into that life, so I stopped being friends with her. I had another friend who I got along great with until he started partying more. My husband and I don't party, so he wouldn't hang out with us much. We do fun things like amusement parks, zoos, travel, etc. Then, he put me on the backburner and stopped talking to me and didn't even go to my college graduation like he promised. Another one was very sweet at first, but soon became manipulative. He would tell me other people don't give a damn about me and will think I'm fat and ugly, but he'll always be there for me. He would play the victim whenever he would hurt my feelings, so my husband and I stopped being friends with him. These are only a few examples. My sister always brags about how she has numerous friends she can count on to be there for her and how none of them do her wrong, and I wish I had friends like that. Why do I always attract people who hurt me? They'll be the sweetest person in the world for a bit, and then suddenly do a 180 on me.