Why do some heavy rainstorms and hailstorms not produce any lightning or thunder at all when I thought that these conditions of heavy rain and hail are right to bring lightning and thunder but don’t and why some tornadoes don’t produced lightning or thunder when the conditions are right for lightning and thunder to form?
For lightning to form there has to be a rising current of air within the cloud, carrying ice crystals and water droplets upwards. The droplets become hail, and start to fall as the air becomes thinner, rubbing some electrons off the minute ice crystals, which continue to rise, now positively charged. The soft hail falls to lower levels and is now negatively charged. Positive and negative charges have a great attraction for each other, as the electromagnetic force is almost unbelievably powerful.
Air is a bad conductor, so although the separated charges gradually build up they won't recombine until the build-up of charge is sufficiently strong to overcome the resistance of the air. Leaders from the oppositely charged regions are constantly probing for a viable passage where a lightning flash can get through to recombine their positive and negative charges.
Sometimes a way is found where the build-up of charge is sufficiently strong to overcome air resistance and a lightning stroke occurs, but if the charge build up is not sufficiently strong no spectacular flash will occur. Instead, the separated charges gradually leak away until charge equilibrium is established. So although it may seem to you that conditions are right for lightning to occur, that may not actually be the case.
More unusually, separation of charge can also happen in dry conditions like dust storms and forest fires, where rising dust particles take the place of water. A vaguely similar process of charge separation takes place in a Van der Graaf generator, which can produce artificial miniature lightning discharges.
Perhaps, a coincidence of a lack of cosmic rays stimulating lightning in that moment could be the variable here that is lacking to kickstart lightning in those two situations mentioned by the question/problem. A Russian physcist named Gurevich proposed that after many years of failed measurements to explain the spark inside a cloud. Gurevich suggested that even cosmic rays coming from halfway across the galaxy could be enough to provide 'a conductive path that initiates lightning'. https://www.scientificamerican.com/article/experts-do-cosmic-rays-cause-lightning/