Just to add to @Gala's post, in general you cannot get a driver licence in a different jurisdiction.
However in most places this law is not (or not really) enforced, or they don't really care about it. For example in the UK you just have to tick a box in the form stating you are a resident (even if you are not).
In the case of Germany however they explicitly have in their respective local law, that any foreign licence obtained while living in Germany is void in Germany. This is in order to combat what they call "driving licence tourism", as they know that the rules of obtaining a licence is harder and more expensive in Germany than in some other countries of the EU.
A foreign driving licence does not entitle you to drive or ride a motor vehicle in the Federal Republic of Germany
(...)
- if your normal residence was in the Federal Republic of Germany at the time you obtained the foreign licence