What happens when you 'delete' something?
A filesystem looks something like this:
00 START NTFS FILESYSTEM
01 START FILE LIST
02 test.txt 6-8
03 molerat.jpg 9-4207
04 END OF FILE LIST
06 Hi Jamie,
07 Could you get two eggs and if they have milk, three?
So the file list contains which file is where and how large it is. Without such a central table, a computer would have to read the whole drive to find any particular file. Or, without a filesystem identifier (line 0), it would have no idea how to read the file list because it doesn't know how it is structured.
You can't delete something: space from a USB stick doesn't go missing. You can only read and write bits on certain positions. So when we say "deleting", we typically mean "overwrite the data with zeroes".
When you delete a file, it deletes the entry in the file list.
When you format a drive, it deletes the filesystem identifier (line 0).
So the files are all still there, you are just missing a reference to them. If you try to read data without having a file table, you don't know whether line 10 is part of another file, or a new file: you'll have to try and find starting markers (such as
JFIF in jpg files) and see if you can read data from there.
To really erase something, you will need software that overwrites the file, not just deletes the file entry. There is lots of software that does this, search for "secure erase" or something. Overwriting a file multiple times is usually not necessary (unless you handle very sensitive data, then you will want to read up on the exact technicalities of the storage medium you're using).
Can data be retrieved from a USB stick after overwriting?
USB sticks and SSDs are very similar in this regard: they are both NAND flash storage, which truly erases a cell's contents when it is told to erase a cell. But each cell can only be written to a certain number of times before it breaks. To use each cell optimally, sticks may do "wear leveling", where it keeps an internal counter of how often each cell has been written to. (SSDs always do this, USB sticks (as far as I know) rarely.) Your secure delete software might try to write
00000 to position 7, but the controller in the device might decide "cell 7 has been written to more than cell 919, so I'll store this new data in 919 instead". Next time the computer asks for the data from position 7, the stick will remember the mapping and return data from cell 919.
Here, too, data might still be present even if your software instructed the stick to overwrite it, though it may be very hard to get it out (you'll probably have to do some soldering to get around the controller and read each cell). TRIM is a command which, when issued to the stick (or SSD), will erase all cells which are marked as empty. So if it has not reused cell 7 yet, then it knows that it is empty (because it knows the data is now stored in cell 919). Whenever it is told to TRIM, it will actually erase the old data. Until it does that, however, the data is still there.