The reason Sony gained success in consoles was because they sought a different audience. Sega and Nintendo were marketing towards children and families (with a few more mature games on the side, EX- Mortal Kombat). But Sony decided to go after the teenage crowd. (A market that really hadn't been tapped.) This let the PS1 fill a gaping hole in entertainment options. And people bought the product. This set the foundation for later systems.
But as for why their other divisions aren't doing so well... It comes down to the fact that there is much stiffer competition. Consider smartphones... For other big names you have Samsung, Google (via the HTC brand), LG, Motorola, apple, Blackberry, Microsoft (and Nokia), plus a number of other smaller names like Hauwei. That's easily 8-10 other choices compare to the console scene where they have basically only Microsoft and Nintendo to contend with. (Note I said console scene... I am not including PCs or mobile gaming here because those are different situations and don't compare so easily.)
Sony also suffers from problems with their marketing just not being there. I mean how many people have heard of the Xperia phone? How many people know how many of them there are? (I didn't even know they released the Z4 until like 6 months after when I was looking up the Z3 again and noticed it.) And the phones actually are pretty decent, specification wise, compared to
other popular phones (the iphone 6s plus and Galaxy Note 5).
Sony Pictures is in a rough spot because they had management that made some choices which didn't go over well. Rebooting Spiderman too early was one major thing, then the whole Ghostbusters
fiasco.