Does Mac power adapter die if you leave it plugged in? I have recently bought a MacBook Pro 15". A couple of days ago I had charged my MacBook and left the charger to the socket and it died. When I tried running diagnostics, it showed that power adapter has to be plugged in. 

There was no sign of power fluctuations, no signs of burning or bulging on the adapter. There were 2 other PC adapter which were left in the same state but nothing went wrong with them. 

The Apple Store initiated a replace of adapter. I would like to know if there is something wrong I have done by leaving it on the socket, because I do it all the time with my PC adapters. I'm new to Apple Macs.
No.  You don't do any damage to a power adapter by leaving it in.

The fact of the matter is that power adapters die for one reason or another. 

Personally, I have power adapters for products that have been in use for well over 15 years, being plugged in all day, every day.  I also have power adapters that barely last a year.  For the most part, my devices that have these types are power supplies are plugged into surge suppressors with most plugged into UPSs; so I couldn't protect them any more than they already are.

In your case, it appear that the power adapter was defective and Apple took care of it under warranty.  Just keep on keeping on; no need to worry about leaving it plugged in.