Unexpected behaviour of operational amplifier in an LDR light sensor
When the lights are on, the LDR can have a very low resistance, say 10 k ohm or less. That means that the voltage at the - input of the LM358 will be around 9 V * 100k/(10k+100k) = 8.1 V

So the opamp then needs to compare at 8.1 V when it's supply is only 9 V. It cannot do that !
 The input voltage range of an LM358 is 0 V to supply voltage - 1.5 V. See "Voltage Range" in table 6.5 of the datasheet

So at a 9 V supply voltage you cannot expect the opamp to work properly above input voltages higher than 7.5 V. To confirm, measure the voltages at the inputs of the opamp and see if these rise above 7.5 V

The simplest way to fix this is to make the opamp's input voltages low when there is a lot of light:







simulate this circuit &ndash; Schematic created using CircuitLab

This then "moves" the issue to the "dark side" (pun intended). If you want to make the circuit better in dark situations you could consider replacing R2 with a 1 Mohm resistor.