https://www.berlin.de/kultur-und-tickets/tipps/kinder/kinder...
https://www.visitberlin.de/en/farms-children
Since most of them are in former West-Berlin the reason they exist can likely be explained from a mixture of empty lots not rebuild after the bombing in WWII, historical farms in outer Groß-Berlin (Domäne Dahlem) and the impracticality of casual trips into the countryside with kids beyond the wall.