A quickish note, as I'm too late to post on the download page for today's GOTD [Black Friday sales]...
Files are stored in pieces or fragments, and the chunks that make up a file may be stored at opposite ends of a partition on a conventional hard drive. Since the read & write heads on a conventional hard drive use a mechanical mechanism that moves them across the disk platters where data's stored, cutting down on how much and how far those heads have to move increases efficiency & performance. And that's how/why defragging a hard drive came to be -- it moves the chunks of data making up a file, so they're all next to one another, usually towards the beginning of the partition where reads & writes are very slightly faster. Most, perhaps all brands of defragmentation software uses Windows APIs.
wikipedia[.]org/wiki/Application_programming_interface
Defragmentation software from Brand X generally differs from Brand Y in features like defragging automatically when the system is inactive, and in the methods used to locate the files most often used on the fastest part of the partition, hopefully speeding things up a slight bit.
SSDs & eMMC storage [eMMC is like a cheaper form of SSD] don't have moving parts, so there's no reason for defragmentaion. It won't hurt anything though -- you might read that running defrag on a SSD is somehow horrific, but in truth all it does is use up some of the finite number of reads & writes that determine the SSD's theoretical lifespan. [SSDs have a rating from the manufacturer that says the drive should last for so many reads & writes, and after that its longevity is undetermined.] Some software, like the defragmentaion routine built into win10, recognizes SSDs & eMMC storage, and so will not attempt to defrag the drives, but will run the Trim operation -- likely why it's called Optimize rather than defrag.
When you write data to a conventional hard drive, it doesn't matter what value was previously stored there -- the new data takes precedence, overwriting anything that was there previously. With an SSD that is not the case, and the storage has to be cleared first before anything new can be written. Obviously that would hurt performance, so old data from deleted files is cleared proactively, and that operation is called Trim. Windows can do it on a schedule, but many [most? all?] current SSDs also have a Trim routine built into their firmware, and will run that regardless whether Windows runs Trim or not.
Windows 10 drive optimization [defragging] has a capability that AFAIK no 3rd party software offers -- it can relocate many immovable files that the others won't touch. And frankly that probably doesn't matter to most people... Where it matters to me is with dynamically expanding VHDs [Virtual Hard Disks]. The single file making up a VHD will grow in size as needed. The footprint of Windows itself changes when there's an update or version upgrade -- it temporarily grows -- so the file making up a dynamically expanding VHD where a Windows VM is installed will grow as well, and stay at that new, larger size. To reduce the size of that VHD on disk, all data has to be moved to the beginning of the partition, all free space "zeroed", and then the VHD is compacted, meaning written to a new file that stops growing when all the data has been written. It's not uncommon for immovable files to exist in isolation several GB into a VHD after a Windows update/upgrade, and win10's optimization is perhaps the only way to get those files out of there, and packed with the rest of the data at the beginning of the partition.