TRIM, when used in the context of storage devices, refers to the TRIM command in the ATA command set and the UNMAP command in the SCSI command set.
TRIM commands are typically used with SSDs. SSDs require TRIM because of a fundamental way of how SSDs operate. Unlike HDDs, SSDs can only program or erase the data in a NAND cell. Because of this, when overwriting or re-programming a cell, SSDs need to go through an erase program cycle which takes longer than a simple program cycle.
The TRIM command is designed to let the SSD controller know which blocks of data on the SSD is no longer valid. On its own, the SSD controller does not know the file structure of the operating system as it only sees bits of data contained within each NAND cell. TRIM helps by letting the controller know when to skip over invalid data. When an entire block of data is marked as invalid, that block is erased thereby returning the NAND block to a fresh state.