"A thousand per tribe, a thousand per tribe" (Numbers 31:4). Some say: he sent two thousand from each and every tribe. And some say: three thousand [from each and every tribe] — twelve thousand armed for war, and twelve thousand who were guarding their equipment, and twelve thousand for prayer. And from where is this derived? Because it is said, "A thousand per tribe, a thousand per tribe" (ibid.).
Why Moses Sent a Thousand Per Tribe Against Midian
Midrash Tanchuma Buber, Matot 4:1
אלף למטה אלף למטה (שם לא ד). יש אומרים שני אלפים מכל שבט ושבט שלח, ויש אומרים שלשת אלפים [מכל שבט ושבט], שנים עשר אלף חלוצי צבא, ושנים עשר אלף שהיו משמרין כליהם, ושנים עשר אלף לתפלה, ומנין שנאמר אלף למטה אלף למטה (שם).