I experienced the exact same issue in the past. The sensor works perfectly when trying to test in a glass of water and in air. But it never works properly when inserted into the soil. From what I noticed, after watering the plant, moisture seems to cling onto the surface of the sensor, and the moisture can't seem to evaporate properly due to it being trapped under the soil. On various occasions, I noticed the soil has gone completely dry, but when I pull out the sensor, I can feel moisture on its surface when touching it.
At first, I have spent weeks trialing and error, using multiple different sensors to ensure it's not an issue with an individual sensor, and I also tried waterproofing the top part where the electronic components were, in case moisture was affecting it, but all did not work out for me. I have never found a solution, and have since given up, because my herbs need watering often in tropical weather. It will probably dry in the end, but I have never waited to try it out, as my plants would have been dead by then.