Make sure to use good brands. I don't use USB pen drives - with built in memory - anymore; rather small USB micro SD card readers. If either the reader or the card breaks down, I get a spare one from the drawer. (That way, I generate only half as much waste.)
There are rumors that sometimes they sell you bad memory cards: cards with factory defects or cards with smaller than indicated capacity. When you fill those completely with data for the first time, you may already experience data loss. So, while I buy the readers from Aliexpress or Ebay, I buy memory cards from a local (Hungary) shop only so that I have some kind of guarantee that they don't sell shit.
Nevertheless, there's the general trend of decreasing product quality and that occurs with
everything, not just pen drives. I don't think there's a solution for that other than making (more) backups. As for hard drives, they can't compete with something like this in size:
https://www.ebay.com/itm/255076951930 .

(Yes, the SDHC card fits into the unused half of the USB plug itself.)