After what period of time does a PhD position count towards the two possible attempts in Germany? 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.