[(Deuteronomy 16:18:) "You shall appoint judges and law officers for yourself in all your gates, etc."] In every single city. "For your tribes" (Deuteronomy, ibid.) — even a city that consists entirely of a single family, appoint judges for yourself. "And they shall judge the people with righteous judgment" (Deuteronomy, ibid.). This teaches you that righteousness is done with both of them: with the innocent one, who takes what is his, and with the guilty one, from under whose hand they remove the stolen goods.
Appointing Righteous Judges in Every City and Tribe
Midrash Tanchuma Buber, Shoftim 5:1
[שופטים ושוטרים תתן לך בכל שעריך וגו']. בכל עיר ועיר. לשבטיך (דברים ט זיח), אפילו עיר שכולה משפחה אחת, מנה לך דיינין. ושפטו את העם משפט צדק (דברים שם). ללמדך שצדקה עושין עם שניהם, עם הזכאי שנוטל את שלו, ועם החייב שמוציאין את הגזילה מתחת ידו.