There are 2 reasons for the different lengths:

  1. The different lengths enable different SSD drive capacities; the longer the drive, the more NAND Flash chips can be mounted on it, in addition to a controller and possibly a DRAM memory chip. The 2230 and 2242 lengths support 1-3 NAND Flash chips while the 2280 and 22110 support up to 8 NAND Flash chips, which can enable a 2TB SSD in the largest M.2 form factor.
  2. Socket space in the system board can limit the M.2 size: Some notebooks can support an M.2 for caching purposes, but only have a small space that will accommodate only a 2242 M.2 SSD (2230 M.2 SSDs are smaller still but not needed in most cases where 2242 M.2 SSDs will fit).