As soon as you get the Admission Letter from your university, the first thing to do is apply for Housing. In Germany housing comes under “Studentenwerk” which deals with everything related to accommodation. Each city has Studentwerk Office in it.
Applying for housing can be done online simply go to website of that city’s Studentwerk, compare the rooms and look on the map whether its near the university/market or not.
For example: If you want to apply to Studentenwerk Berlin, simple google Studentwerk Berlin and you’ll get their website.
Note: Mostly crowded cities like Berlin and Munich it is very hard to get accommodation in Studentenwerk, you’ll have to look for private options. If this is the case post in Facebook Groups (links of groups given here). There are Pakistan Student Associations in each city and they have their Facebook groups too (read: Pakistan Student Associations in Germany), join those groups and ask for guidance.