I am not sure if this holds true everywhere, but here in Germany you only get two attemps at getting your PhD. I am currently wondering at which point it counts towards those two attempts. If I were to start a position and quit during the first few weeks, would it still count?
I don't think this is quite true in Germany either - or at least not in the generality that I read into your question.
Here is example 1 (Promotionsordnung (PhD bylaws) for psychology and sport, Muenster), and another randomly selected example 2 (Promotionsordnung math, Bonn). Both stipulate much more restrictive conditions that relate to your question. They somewhat overlap, but not completely - so there is also no uniform answer for Germany. Simply stepping away from a PhD early on would not be a problem in either case. The restrictions on the number of attempts to be successfully awarded a PhD are as follows:
Example 1: you get one and one only attempt to resubmit a declined thesis, and to re-take the oral defense each
Example 2: no restrictions are mentioned on the number of failed thesis attempts. You get one attempt to re-take a failed defense
In particular given that even these two sources don't agree, you just need to pull your program's Promotionsordnung, and confirm which rules apply to you.
I think you are conflating the issue of being a Wissenschaftliche Mitarbeiter (research personnel) with that of receiving a PhD. It is possible to work in a "research" position for an extended period of time without being part of a PhD process, so such positions obviously would not count towards "two attempts."
In addition, it is entirely possible that people might have to move or change positions because of personal circumstances (health, parental leave, or the two-body problem, among other reasons). Restricting people to two "shots" in this manner would be unfair.
Instead, I believe what you are referring to is the rule that there are at most two attempts at the thesis defense. If you fail the first one, then you must wait for a prescribed period of time (but not longer than another period of time), and attempt again to defend your thesis. If the second attempt fails, then you are not allowed further attempts. (However, if you work with your advisor, there shouldn't be a problem here, as you shouldn't be allowed to hold a defense if there's a substantial risk of failure!)