If the handlebars are too far away and can't be fixed with a shorter stem, the top tube is too long. If the top tube is too long, the frame is too big. It sound like you have long legs short arms, if so you need a shorter top tube, ergo you need a small in a compact geometry.
I'm 5'8" and ride a 50cm Trek. I "could" ride a 52cm Trek but there wouldn't be enough seatpost showing to use a seatpack. Other riders I know that are my height ride 54-56cm bikes. It's not about which size the manufacturer claims will fit based on your height, it's about how your various body dimensions dictate what size frame you need.
You should go back to where you bought it and get them to either make the bike fit (unlikely anybody can) or give you a bike that will fit.