It's written in this Torah portion that a king isn't allowed to acquire any horses for himself, because it will cause people to go to Egypt and buy them, and it is forbidden to return to Egypt.
Rashi to that verse (Devarim 17:16), from Sanhedrin 21b, says that 1) the horses come specifically from Egypt, so it would violate a mitzvah to return there so we "don't see them again" (Shemos 14:13) (even though all of the Egyptians of that time were supposedly wiped out at the splitting of the sea, but that's a separate question) and 2) it's ok for him to acquire horses necessary for his army's chariots.
The question arises:
If he's not allowed to get horses for himself because it will cause someone to return to Egypt (thus violating a mitzvah) to buy the horses, since that's the only source of horses from Eretz Yisroel according to Rashi and the Gemara, then how is he supposed to buy horses for his army?