Ideantical products? That's hard to imagine but, even if the two products respond to the same need, there is definitely a reason why a product sells more than the other one. At the moment of purchasing, the emotional side is definitely a reason, like the customer's mood in that particular moment in time. But answering that these elements make the difference is reductive.
There are a few factors to consider. First of all the life span. How long has each product been around for? If one of them was launched earlier it has a bigger chance to win a larger share of the market. Second, the way those products are advertised; some marketing campaigns definitely add a value to the product's success. The quality of their online presence is determined by Marketing initiatives too and by the time and ideas developed around those initiatives. Furthermore, the opinions of the end users about the quality or effectiveness of the product is a key value to create interest in a product rather than another.
But one thing to definitely consider is the way the products are presented, the feelings created around them, the quality of the communication of its benefits. For instance a product that is presented with a number of good case studies is able to gain more attention and the customers can identify themselves with that particular story.
A number of customers is definitely acting emotionally, but details make the difference. So, if you want to win a client, always try to show that your product is much more than what they think, and make sure you deliver that promise.
Last but not least, if you don't know who you are talking to, it's quite hard to explain your values in the right way. So make sure you understand very well your audience and you talk to them in the right way.