(Deuteronomy 16:18:) JUDGES AND OFFICERS. JUDGES — these are the magistrates; and OFFICERS — these are the leaders who govern the congregation. Rabbi Eleazar said: If there is no officer, there is no judge. How so? When a person has been found liable to his fellow in court, if there is no officer there to exact payment from him, then once he has departed from the judges, it is not within the judge's power to do anything to him — unless he hands him over into the charge of an officer, and the officer exacts payment from him. Rabbi Eleazar ben Pedat said: Were it not for the enforcing authority of Joab, David could not have carried out justice. And so it says (in 1 Chronicles 18:14-15): "And David executed judgment and righteousness for all his people, and Joab son of Zeruiah was over the army." Now were David and Joab judges? Rather, anyone who would not heed the judge — they would hand him over into the charge of Joab, and they would exact compliance from him against his will. And so Job said (in Job 29:16-17): "I was a father to the needy... and I broke the fangs of the wrongdoer."
Why Judges Need Officers and How Joab Enforced David's Justice
Midrash Tanchuma Buber, Shoftim 3:1
שופטים ושוטרים. שופטים אילו הדיינין, ושוטרים אילו פרנסים שמנהיגין את העדה, ר' אלעזר אמר אם אין שוטר אין שופט, כיצד כיון שנתחייב אדם בבית דין לחבירו, אם אין שם שוטר שיוציא ממנו, כיון שפירש מן הדיינין, אין ספיקה ביד הדיין לעשות לו כלום, אלא אם כן מוסרו ביד שוטר, והשוטר מוציא ממנו. אמר ר' אלעזר בן פדת אילמלא שיטנו של יואב, לא היה דוד יכול לעשות את הדין וכן הוא אומר ויהי (דוד) עושה משפט וצדקה לכל עמו ויואב בן צרויה על הצבא (דה"א יח יד טו), וכי דוד ויואב שופטים היו, אלא כל מי שאינו שומע לדיין, מוסרין אותו ביד יואב, ומוציאין ממנו בעל כרחו, וכן איוב אמר אב אנכי לאביונים וגו' ואשברה מתלעות עול (איוב כט טז יז).