The first two digits in the battery number refer to the nominal diameter in millimeters (17500, 17650, 18500, 18650). The second pair of digits refer to the nominal length of the battery (17500, 17650, 18500, 18650). The 17650 and 18650 are roughly equivalent in length to two CR123 primaries. Two 17500's or 18500's are roughly equivalent to three CR123 primaries.
The 17500 and 17650 are often used in flashlight hosts that were designed for standard CR123's but that aren't large enough to accept 18mm batteries with the most common examples being stock Surefire lights. For example, using a 17650 in a stock 6P, C2, or Z2 body or using two 17500's in a stock 9P, C3, or Z3.
The 18500 and 18650 have the same application in hosts that are large enough to accept them. Examples include bored Surefire hosts, Malkoff light bodies, and several other brands.
All of the above refers to the physical size of the batteries. When switching from primaries to Li-Ions, voltage must also be considered. (CR123's = 3 volts each, Li-Ion's = 4.2 volts each). Unlike incandescent bulbs, LED's usually operate efficiently across a range of voltages but care must still be taken to ensure the battery combination falls within range for a given light.
Edit: I type too slow. Good answer PCC