HDD - Bits of data are arranged in concentric, circular paths called tracks. Each track is broken up into smaller areas called sectors. Part of the hard drive stores a map of sectors that have already been used up and others that are still free. With a HDD, data is not deleted, the markers that point towards that data are removed. You if want to permanently delete data it must be written over using 1 and 0 so you can no longer access that data. Multiple passes make it more difficult to recover data. There are a few occurrences where data does not get over written. If the drive has damaged or corrupted cells the drive ignores them when writing the 1 and 0 potential leaving the data that was stored there recoverable.
SSD - Storing data in SSDs is more complex as compared to HDD. All the data in a block must be refreshed when any portion of it is updated. The data on the old block is copied to a different block, the block is erased, and the data is rewritten with the changes to a new block. SSD must remove the data from the flash memory. This is where TRIM comes in. The TRIM command enables an operating system to notify the SSD of pages which no longer contain valid data. For a file deletion operation, the operating system will mark the file's sectors as free for new data, then send a TRIM command to the SSD. After trimming, the SSD will not preserve any contents of the block when writing new data to a page of flash memory, resulting in less write amplification (fewer writes), higher write throughput (no need for a read-erase-modify sequence), thus increasing drive life. When wiping an entire drive this is not complicated, but when trying to securely remove individual or groups of files it can get tricky and sometimes you will remove or corrupt data outside of the data you were intending to remove. Overwriting sectors with 1 and 0 does not always ensure file deletion on a SSD. It is possible to remove the flash memory chips from a SSD and attempt to recover data from them.
The drive on the left is a HDD and the drive on the right is a SSD:
Brant, T., 2021. SSD vs. HDD: What's the Difference?. [online] PCMAG. Available at: <https://www.pcmag.com/news/ssd-vs-hdd-whats-the-difference> [Accessed 13 April 2021].