Does the duration of doctoral and postdoctoral phase *always* matter for a W1 position in Germany?
There are two different regulations applying here:

On the federal level, it is mandated that barring exceptional circumstances, a researcher is not supposed to exceed 12 years in total on temporary German university positions. Since a typical duration for a junior professorship is 6 years, that would mean no more than 6 years of temporary employment at German universities before that. This rule does not apply to certain external funding sources inside Germany, and not at all to positions held outside of Germany. Thus, this imposes a rather tight deadline on people intending to have their whole career in Germany, but does not matter much for those who are doing part of their career elsewhere.

In addition, each state has their own law describing who exactly is eligible to become a junior professor. For example, in Hamburg one may not have more than 3 years of postdoc experience. Since there are 16 states, listing all laws is not feasible for me. Also, do not count on this information being listed explicitly in job adverts.