The PS4 gives great performance for the price, better than the Xbox One. This made it more attractive ($100 cheaper in the US market, or 20% cheaper, is huge). Furthermore, both consoles lacked compelling and numerous exclusives, so people could mostly make the decision based on price and theoretical stats (not that most people do the latter well, mostly they just look at the numbers and go with the bigger ones). Nintendo, as always, has its own market corner and mostly stays there (not that that corner is small or anything!).
The problems with the PS3 were its price, both for customers and for Sony, and relative lack of exclusives. Sony was selling at a loss throughout most of the life of the console, even more than Microsoft was (which also sold at a loss, although not such a huge one). This ate a lot of profits and still the console was too expensive for the end user. Also, in the console market, which sadly is very driven by the desire to be able to play games that other people cannot (i.e. exclusives) and having games on your platform that are consciously and maliciously denied to other platforms is viewed as something positive. Xbox 360 had better exclusives and the Halo franchise, as always, was its saving grace.