Dark was developed by Jantje Friese (author, but there were also other authors) and Baran Bo Odar (director). English wikipedia, German wikipedia. In an interview with serienjunkies.de from 2017
Friese explains that the idea is pretty old, 7 to 8 years (around 2009 and 2010) and originally supposed to be a movie but also continually changed over the years. When Netflix asked them to turn one of their movies (Who Am I) into a series, they suggested to do Dark instead. They had another idea and combined it with the Dark idea. That became the Netflix series Dark.
In a 2019 interview with DWDL.de they were asked if Dark would really end after the third season and Odar answered
Das war von Anfang an der Plan, und er bleibt es auch. Wir wollten nie
das Schicksal von "Lost" teilen, das klar ersichtlich auf drei
Staffeln ausgelegt war, wegen des Riesenerfolgs aber immer noch weiter
und weiter fortgesetzt wurde.
Summarized and paraphrased:
They planned from the beginning to restrict it to three seasons. They didn't want to share the fate of Lost that was also planned for three seasons but then prolonged due to its success.
In an interview with deadline after season 1 had been finished, they were asked if there'd be a second season. Friese said
Wir alle – das ist Konsens – sind sehr zufrieden mit dem Endresultat,
und natürlich haben wir Lust auf mehr, auf eine zweite Staffel, der
Rahmen ließe das auch zu.
And Odar
Jetzt müssen wir mal abwarten, wie DARK ankommt, wie das Publikum die
Show annimmt, dann ist alles möglich...
Summarized and paraphrased:
After season 1 they were interested in a second season and the material would allow for it, but you had to wait for the first season's reception.
TV Movie quoted the developers in 2020
'DARK' war bereits in der Konzeption als Zeitreise-Trilogie geplant. Umso glücklicher waren wir, dass die erste Staffel um die Verstrickungen der Bewohner von Winden durch Raum und Zeit auf so viel Zuschauerliebe weltweit getroffen ist. Es wird zwar auch für uns sehr traurig sein, sich von den uns ans Herz gewachsenen Figuren zu trennen, aber der Anfang ist das Ende und das Ende ist der Anfang.
Summarized and paraphrased:
Saying again that it was planned as a trilogy and that they were happy that the first season became a success so that they could shoot also the rest of it.
Conclusion
It seems that it is based on a general idea that also had a natural end after 3 seasons, but was flexible enough for fewer seasons.
The interviews also showed that most of the writing took place during the filming of a season (and they also had other authors), so they put the general idea they start with into practice, both into scripts and then on film. You need to remain flexible because, as Odar said in the end, you had to wait for the series' reception. If you work too much up front and the first season is unsuccessful, the work would have largely been for nothing. It's not so clear how many of the smaller details had been planned beforehand.