Check to see if you’re threshold is too high or low, maybe you’re pumping water for too long. Maybe you should wait longer between checking to see if you should water your plant.
You might have one of those pots with a saucer that keeps excess water and slowly feeds it back to the plant, have a think about whether the moisture sensor could hang in there instead of in the soil, think about if you would have to change the threshold value if you did do that.
Try coding in an extra bit of text that says “checking soil moisture” before the initial reading so that you can catch when it’s checking the soil moisture.
You could try and see if you can code it in such a way that you will always be seeing what the sensor is reading while at the same time doing the regular code.
Maybe you could code it so that when it pumps water it is also recording how much water has been pumped and stops running once a certain water pumping threshold has been reached.