There are many reasons a hard drive or USB pen can fail, and the same is true for phones and tablets. They can all loose their data or fail in some way that results in loss of data.
Hard drives often have to be dismantled and put into special machines that read the metal discs and slowly read all the data. There are normally 2 metal discs inside the drive, and when removing them care must be taken to keep them perfectly straight in their original alignment right up to the point when they are secured into the recovery machine.
This slightest misalignment means total loss of data as there is no way to correctly realign the discs; they won't have their cylinders lined up. Each cylinder passes through both top and underside of each disc inside the drive.
Mobile phones and tablets can hold SD memory cards which can also fail, but the worst failure would be the device itself, because if that breaks you can't get to the internal memory to get back your pictures or music. In this case the device has to be taken apart and then the Emmc memory chip found and carefuly removed from device's motherboard. This chip is then cleaned and the solder pads resoldered. The chip is then put in a machine that helps recover data from it.