Your eyes adjust to light based on an average. If your whole room is dark and the only light is from your device, then your eyes are adjusted to the overall darkness, leaving the device screen outside of that range which causes the discomfor. Darkmode might prevent that from happening by lowering the amount of light from your device and matching it to your environment.
Dark mode on an OLED screen means less light is entering your eyes. The contrast between the text and the background might be way harsher in dark mode though. When in light mode, the text might not actually be black, it might be a dark grey or something. But in darkmode the contrast is white light against no light.
maybe a middle ground dark mode that has dark grey background and light grey text would be good for you
This is true af. I have an astigmatism in both eyes but I still prefer darkmode. Mainly because of the look, but at night light mode is way worse than the blurry text (which is solved by increasing the font size)