I believe there are a couple of factors at play here.
First of all, most (perhaps all) of those people are Hungarian Jews, and Jewish people (imho) are both very intelligent and their culture values education a lot. Hungary had a very large Jewish population at the time, so no wonder we produced so many great scientists!
Second is the Hungarian language. Ede Teller specifically said his scientific achievements are thanks to the Hungarian language, and without it he could only be a high school teacher. I can find a few sources if you want, and the ones I know about might not be accurate, but for example Cardinal Giuseppe Mezzofanti, who spoke 58 languages himself, said of our language: “Do you know which language, because of its constructive ability and the harmony of its rhythm, comes before all the others? The Hungarian! It seems as if the Hungarians themselves do not know the treasure of their language…”.
Third Hungary at that point was a rather developed country, unlike now. Budapest metro opened after the London one, as the worlds' second.
Edit: Fourth, not related to the previous 3 as not unique to Hungary, but there were probably "network effects" at play. Science does not happen in a vacuum, as Paul Erdos said for him maths is a social activity (as witnessed by his vagabond tendency to move in with his peers and work on problems while living at their house). So probably having all these great minds in related fields was a kind of a feedback loop.