LayerList widget has a documented feture:
To hide layers in the map from the LayerList widget, you must set the listMode property on the desired layers to hide.
I tried to use this feature over several layers in a loop and found strange behavior - only each "second" layer is hidden when you change listMode property of several layers in a loop.
Here is an example: https://codepen.io/alexanderryzhov/pen/OJyrPdj
If you turn off "first half" of layers (from 0 to 4) only layers 0,2,4 are hidden actually and #1 and 3 are still here!