I always was convinced that so many animes take place in Highschool was because your ordinary Japanese citizen living in one of their tightly packed Can-of-sardines cities lives a daily life of unfulfilling frustration and stress, and the last time they experienced genuine happiness was in the rose-tinted halcyon days of their youth in Highschool. So they just "write what you know" or at the very least perceive that they know.
Don't overestimate how widespread the popularity of anime is in Japan. A few thousand dvds is considered good sales of an anime DVD volume, compared to mainstream live action films which will be watched by millions of people. Almost all this stuff we're talking about is incredibly niche, and the majority of Japanese people are definitely less familiar with the whole range of available titles than us in this thread, so it's not really possible to draw conclusions about Japanese people as a whole from this.
Also, the school setting is far more prevalent in shonen and shoujo, which are created specifically for younger audiences, than they are in anything created for an adult audience, so that kind of puts into question whether nostalgia is the main thing, or whether they're creating a lot of teen material that is in fact aimed at teens.
Anyway, whether or not nostalgia is at play, your analysis of Japanese high school seems totally off. Japanese highschool is not fun and games, so I doubt that the vast bulk of Japanese people had a carefree highschool life which they look back on with fondness in their grim adult life. I'm betting that adult life gives you a lot more freedom: In highschool you had exams, parents pressuring you to do well, cram school etc. And they have to do entrance exams every 3 years to get into the next school. Once you're an adult you can drink and have sex, live on your own etc. Much better.
Also you're overestimating how crowded Japan is. It has less population density than Holland, Belgium or Israel, and I doubt you consider any of those crowded places.