Sparse disk images (and sparse bundle disk images), created for example using the New Blank Disk Image… command, grow in size when you add files to them. When you remove files from them and empty the trash, the space is available for adding more files, but it is still “reserved” for use by the disk image. Thus, the size of the disk image file does not automatically decrease. The Compact Image… command lets you reclaim the unused space, thus shrinking the disk image file.
Depending on how fragmented the contents of the sparse disk image are, it may not be possible to reclaim all of the unused space. (It may help to use a defragmentation utility such as iDefrag or Drive Genius.) To shrink your sparse disk image to the minimum possible size, use the Convert Image/Archive… command to create a fresh file.
You can hold down the Command or Shift key to select multiple files for compacting.