Spacing of G and K class stars I was looking at the Wikipedia article "List of potentially habitable exoplanets" and I noticed that many of the closest planets listed(tens or hundreds instead of thousands of light-years away) orbited M-class stars. I have also read that scientists are more certain about the possibility of habitable planets around G and K class stars, because the habitability of red dwarf systems is still debated. I was wondering whether there is something that makes the larger stars be farther away from each other, or whether it is just a coincidence. So is it possible to have many G and K class stars tens of light years near each other?
The solution to your mystery about why habitable planets are found around nearby low-mass stars, but distant G/K stars is all to do with observational selection effects and biases. There are many G/K stars within 100 light years of the Sun, but almost none have been examined in the detail required to reveal small, habitable planets around them.

Almost all the small "Earthlike" planets in habitable zones have been found by the transit technique. It is much easier to find such planets around small stars for two reasons:

The transit technique yields a signal that depends on $(R_p/R_{*})^2$. Thus small planet transits are easier to see around small stars.

The probability of a transit depends on the ratio of the star size to orbital radius. This sounds like it works against finding planets around small stars; and it does at a fixed orbital radius. But, because the habitable zone is much closer-in to a smaller, less luminous star, then the habitable planets around such stars are more likely to transit. In addition, their orbital periods will be tens of days rather than the months to a year around G/K stars and this makes it much easier to observe repeated transits.

In fact, the combination of these two selection effects makes it possible to find habitable zone planets around small stars all over the sky from ground-based observatories.

The downside is that small stars are low luminosity, so the planets that can be found are found around nearby examples at tens of light years.

In contrast, habitable zone planets around G/K stars are mostly found in months-year orbits by Kepler, which stared at a single small field for 4 years. The majority of the stars targeted by Kepler for exoplanet searches were 10th-15th magnitude G/K stars (there are few brighter examples in such a limited patch of sky), which are at distances of hundreds to thousands of light years.