It's cultural knowledge passed down through generations. Mushroom foraging is super popular in Russia and other Slavic countries, and my grandmother taught me most of the fundamentals before we immigrated to the US, and I continued to study field guide books on my own.
When you get to know the specific bits of anatomy of the mushroom body, the trees with which they're symbiotic, the seasons in which they occur, etc., then identifying different varieties becomes as clear as identifying a baseball vs. a tennis ball.
Incidentally, I've heard that a significant number of people get poisoned by mushrooms when they learned to recognize edible mushrooms in another country (often China or Eastern Europe), then move to the US and try to forage for mushrooms here. Knowing one region's edible/poisonous mushrooms doesn't make you an expert on anything outside that region.
It it worse than not being an expert on local mushrooms.
You can get fooled because you can find mushrooms that resembles mushroom from you home region, that you know to be edible.
E.g:
https://en.wikipedia.org/wiki/Volvopluteus_gloiocephalus#Edi...
==
In the United States, there have been several cases of Asian immigrants collecting and eating death caps (Amanita phalloides), under the mistaken assumption that they were Volvariella.
==
books with photos, very in-depth descriptions, pictures and descriptions sent to friends who also forage, and when all else fails, spore samples.
I've only had to make it to spore samples 6-7 times because I couldn't identify with the first three methods. I will note that I never ate any of the ones I took spore samples of - because I was then able to correctly identify them as poisonous (or close enough that I wasn't willing to take the chance).