Hard drive
A hard drive records data (text, images, databases, programs) on a rotating magnetic platform. Originally indepent peripherals, a desktop PC will usually have one built in. Ones with larger capacity are available as add-ons that attach to a USB port, the main way peripherals are attached. This is the same technology used in server farms such as the ones Google, Youtube, and Pornhub use. Theirs are on vertical racks with plug-in cards of hard drives. (And produce tons of waste heat).
Other technologies have partly replaced magnetic hard drives in consumer products: read-write optical drives (CDs, DVDs, and BluRay discs use this technology), and using RAM circuits (look it up in Wikipedia) to act as memory, thus producing memory sticks and virtual hard drives. These are too expensive for use in servers, but are suitable for consumers who have only a few gigabytes of data.
Encryption
Data on a storage device can be encrypted, that is requiring some kind of password or similar to decode. Encyption is a major military topic. Both sides - as in World War Two - struggle to come with up with an encryption protocol that the other side can not figure out how to decode. By the way, Osama bin Laden, who we should never forget had a porn collection (that's a militarily important bit of information), did not use encryption. He used human messengers. If you know where your enemy is, which means you know who he is, you can figure out who sees him and where they came from. Making them talk, if you capture one, is sometimes possible. Check Guantanamo and Abu Ghraib. What Is harder is figuring out whether what he tells you is useful - he may know what you want to learn, and makes something up to try to get you to stop, he may know what you want to know, but tells you a deliberate lie instead, or he tells you the truth, but you have to distinguish it from everything else he's said.
Briefly, the longer the passcode, the more protected the data is; it would take more time to try every possible code, what cryptographers call the "brute force" method. This is in essence the technique used by PGP ([[[Pretty Good Privacy]]) and many commercial encryption applications, who may claim that their protection has never been broken, which is true but not cause for relaxation. (in military applications it's more complicated, there may be a separate passcode for each character, as in the Nazi's Enigma machine, which the Allies decoded thus changing the course of World War Two.
The government is not going to use a brute force method on you. It is too resource-intensive, and incredible as it seems, there are on the other side some who think it's more important to use their finite to go after terrorists rather than boylovers, girllovers, or child porn collectors. There are too many of them, and the authorities have all the cases they can handle using other methods.
Forensic analysis
What follows deals exclusively with the older magnetic technology.
In an operating system such as Windows, there are temporary files and logs all over the place. Even with the browser in Private mode. Can these be erased? Sure, if you know what they are and how to do it. You can easily buy programs that claim to carry out military-grade erasure, which considers overwriting with multiple passes of ones and zeros. This cannot be done between the knock on the door and the law enforcement official reaching the drive and unplugging it from its power supply. Can the erasure truly prevent recovery of data? I don't know. A lawyer who has been to workshops says the only safe thing is to physically destroy the disk platter, bending it with a hammer or etching it with acid. Drives are cheap. Buy a new one.
In a forensic laboratory such as state police etc. will run, erased files and the like are recovered.
(Uncompleted)