I love this analogy. Not only is it a good analogy, the underlying mechanisms causing bugs to be drawn to light and humans to be drawn to instant gratification are both results of our biology and evolution through thousands of years of life before modern civilization, and both can have really devastating outcomes in modern society.
My understanding is that bugs are not actually drawn to light, but rather attempt to fly at a fixed angle to light, roughly perpendicular to it. When the light is the Moon, that keeps them flying in more or less a straight line. But when the light is close to them, they turn to keep the light at that fixed angle and consequently spiral in towards it.