It had to do with FOCUS.

The answer, like always, is to be found inside the question which generates it.

“If socialism is so bad, how did the Soviet Union produce so many scientists.”

The key word here is ‘produce’.
First of all, Russia did have an important cultural and scientific tradition to start with.
Secondly, the communist leaders – mostly Lenin but more or less all of them, had a clear understanding of the literacy gap which separated Russia from the rest of the world. Filling that gap was the first step towards Russia/the Soviet Union becoming a First Tier country. Hence the ‘free, standard, universally available education’.

But there’s a caveat here.
When we’re speaking about education – in the West, we mean ‘everything already known to man’.
Students are allowed to read everything in the library – except for certain places in the US, but those are exceptions.
When we speak about the education in the Soviet Union we must remember that each of the ‘free, standard and universally available’ aspects had its own limitations.
It was free in the sense that everybody – well, almost – had the right to apply for it. Actually getting it was something else.
It was standard in the sense that it was standardized. Only what was deemed safe/useful was allowed to reach the students.
It was universally available in the sense that everybody was subjected to some form of education. Much of which was nothing more than indoctrination…

Finally, let’s remember that the Soviet Union was able to produce scientists only for so long. Until it collapsed under it’s own weight…

Moral of the story?

Producing scientists is not enough.
Science teaches you only how to do whatever you want to do.
What to want… that’s something else!