Files and metadata gets updated, and if the file grows that often makes fragments in the file. Therefore, defragmenting HDDs is something you should do often. Windows 7 does this automatically.
Defragmenting requires alot of free disk space to be effective. Best not to fill your filesystem beyond 70-75%.
SSD or Solid State Disks should never be defragmented, and doing so may be harmful. For that reason Windows 7 disables defragmenting on SSDs, but this 'detection' does not work if you used a cloning program to migrate a HDD-install to your new SSD. Recommended to install fresh on SSD.
If a file contiguous to other files, is modified or deleted, it leaves a 'gap' (free space) in between the files. When Windows writes a new file to the disk, it might start writing that file in the first 'gap' that it comes across despite having plenty of contiguous free space elsewhere. If this 'gap' is not big enough to hold the newly written file, then part of the file is written elsewhere (the next free gap)..so on and so forth until the entire file is written to disk. This is fragmentation, it is inevitable, and occurs continuously as windows keeps modifying/creating/deleting files, that's why regular defrag is recommended.
Heavy fragmentation can reduce filesystem performance because it takes longer to read and write a fragmented file. When you defrag, the file fragments are rearranged to make the files contiguous, and often the free space is also consolidated so that new files can be written contiguously instead of in fragments.
These days, defrag is an automatic process: there are powerful defrag utilities that monitor the drives 'behind the scenes' and defrag whenever necessary without bothering the user (BTW windows defragger is not really 'automatic'; it is triggered on a schedule). The best auto defrag utilities can even prevent most of the fragmention as new files are added. These utilities can also defrag with less than 15% free space...some work with even less than 5%.