Here's basically the way data recovery works on a formatted volume. When you delete or format a drive or usb or most types of media, it will wipe a few sectors in the begining of the drives that has the partition info and create a new partition. Now when the system looks at the drive it has a new partition and therefore looks empty. In truth most of the data wasn't touched as long as you dont continue using it. Now that theres a new partition in place it tells trhe computer or camera that all these sectors are available to be used and therefore as you continue using it you will overwrite the old data.
How the recovery works. Most data recovery software skips the partition data, and scan each sector looking for file info. Every type of file has unique data written to the actual sectors. If we were to look at them in hex you would see that each type of file has a header at the begining of teh file and a footer at the end of the file. For example a typical jpg image header (start of file) is ff d8 and the footer (end of file) is ff d9. The recovery software looks for hex data (sectors) starting in ffd8 and ending in ffd8 and determines accordingly what type of file this is. Some software have better algorythms than others and have deeper scanning ability than others to figure it out. But in simple terms this is how data recovery works on formatted and deleted media.