Fragmentation can occur when an SSD has less than 25% of free space left.
The reason for this is in how an SSD stores its data.
Your entire SSD is made out of clusters. Each cluster has sectors in it which can be filled with data.
When a file is written to your SSD, it will be written to a new cluster. It is done in such way that speed is guaranteed. When a file is removed, it will check if that cluster is empty and if so, it is marked as cleared. This is done by the function TRIM.
Now, the problem is, that at some point, your drive will be filled with enough data to make all available clusters filled with some data. This is not a bad thing, because most clusters will still have some empty space in them. When a new file is written it will then be stored in one or more of these clusters. It is here where your drive looses its speed. Not so much by how the file is stored, but because it has to find empty space rather than just finding the next empty cluster.
After your drive has been fragmented, and a file is deleted, the chance becomes small that the cluster that file was in, is completely empty. If the cluster is not empty, TRIM will not mark that cluster as cleared, and thus it will not be moved to the pool of free clusters.
So in order to fix this, first make sure you have at least 50% of free space on your SSD available, then find a defragmentation tool especially for SSD drives.
If you have another disk available, and the SSD is not running your OS, you can consider moving all your files from the SSD to another disk and then format your SSD. This will cause TRIM to mark all your clusters as empty and moving the data back will do so without causing fragmentation. Do note, this last move method is not necessarily better than a defragger. These defraggers will try to move as little data as possible while obtaining the goal, whereas moving all data to your other drive will essentially cause all clusters to be written from and to atleast two times.
One last note: The 25% of free space is a rule of thumb, not an actual established fact. Each drive is different, and with some drives it happens earlier, with some drives it happens later. So for convenience, make sure you always have at least 25% of free space on your SSD. So if your SSD is 240GB big, make sure you have at least 60GB of free space to avoid fragmentation.