Can I apply for a second PhD position in Germany? I had a scientific-assistant position from April 2012 till December 2016. I had two children in between and took the necessary time off, the extension of contract due to this break is also included in the time mentioned in the beginning. Now I am trying to finish the thesis, but I am not very happy with the quality of results and am finding it hard to defend. 

Rather than finish, can I apply for another PhD position or not?
You may write another thesis, however, you will not be able to be employed on a limited-time contract in this capacity again due to the Wissenschaftszeitvertragsgesetz. So doing a second PhD means doing it without any financial support (unless you are able to get a scholarship, but all funding sources I know of require that it's your first time).

ETA: Based on comments and the other answer, you may actually be allowed to continue on a limited-time contract still for 4 years plus the length of your maternity leaves. In this case it seems possible to complete another PhD in this time if you can get another position.

However, if it's only the lack of time/distraction of children that lead to your current thesis not being where you want it to be yet, it would seem more worthwhile to invest the time to improve it. Unless you have significant issues with your current advisor/lab that you didn't mention, there's no reason to think your results would suddenly be so much nicer the second time around!