How to get over a fear of commitment?

I have no idea why, but I'm scared by relationships. I'll start liking a guy but then I'll start getting really confused and unsure and when we start getting closer and more comfortable I start backing out and shutting out the guy. I know it's bad, but for some reason I have a fear of commitment and I want to know how to stop being so afraid.

Updates:

Like there will be sparks and we'll be together but then suddenly I get scared and stop liking him. I used to last a couple weeks before breaking up with a guy but lately it's been right before we get together.