You are right, IOS are files located in directories.
The directory name represent the slot number. (it's named with an hex value from 00000000 to 0000101 (slot257).
it's stored in /title/00000001/ folder on the NAND.
Slots from 1 to 80 are used by nintendo, plus slot 256 and 257.
/title/00000001/00000009/ is IOS slot 9
/title/00000001/00000024/ is IOS slot 36
/title/00000001/0000003A/ is IOS slot 58
etc. to slot80
/title/00000001/00000100/ is MIOS
/title/00000001/00000101/ is BC
Slot 81 to 255 are unused by nintendo, so hackers use them to place their own patched IOS files or programs in it.
as a common rule, hackers don't install custom IOS below slots 200 (as nintendo added them in incrementing order, it left enough spaces to not conflict with future updates)
For example:
IOS236 is actually a patched version of the system files located in the folder /title/00000001/00000024/, and the result is copied in folder /title/00000001/000000EC/
IOS 236 is "based on IOS 36".
It's the same with all other cIOS.
There is a "base IOS" which are patched, and the resulted files are copied to another slot.
d2x cIOS 249[56] = original IOS56 from nintendo patched using the d2x program to add more functions (EmuNAND, Wii games from USB, FAT32, etc.), and the result is installed in slot 249.
each slot is a full system by itself (wiimote functions, NAND functions, external device functions, etc.).
instead of updating the existing system files (like a Firmware update would do on other consoles), nintendo is using a method to keep old files intact for old games, and use new files for new games. Probably in fear that an update would break old games, and there's no way to download fixes for individual games.
they install new versions in new slots instead of updating older files.
Old games (like Zelda Twilight Princess) still use IOS9 and it hasn't been updated/replaced (except bug fixes, but no new features were added to it).
If a IOS had a new feature (for example adding USB2.0 support for games like WiiSpeak/animal crossing), it was installed on a new slot, and games requiring USB2.0 access only use the system files located in that folder.
a IOS is in fact multiple set of files, not a single one.
There are also shared IOS files, which are single files identical for all IOS. instead of having multiple copied of the same file, they are stored in the /shared1/ folder on the NAND.