After explaining in 8:17 that the plague of 'arov' is a mixture of wild animals which descended upon Egypt and killed some Egyptians, Rashi goes on to explain that the Medrash Tanchuma provides the reason for each plague. The reasons follow a military strategy of staged attacks against a city, giving time in between stages for the enemy to surrender. First the water supply is attacked (blood), then terrifying noises are made (croaking frogs), then arrows are shot (lice), then barbarians (wild animals) are dispatched to attack, etc. The obvious questions are, first, Rashi doesn't simply quote interesting medrashim for us - there must something incongruous in the psukim which Rashi is addressing by telling us this elaborate Tanchuma. Second, whatever the necessity of quoting the Tanchuma might be, why doesn't Rashi quote it for us at the beginning or end of all the plagues, but instead inserts it as a seeming afterthought following his explanation of arov.
In fact there is a machlokes (dispute) in the Medrash Rabbah (11:3) concerning the arov. Rabbi Yehuda maintains that the arov was a mixture of wild animals (bears, lions, leopards, etc.) that would kill some of the Egyptians (like barbarians kill); Rabbi Nechemia says that the arov was a mixture of annoying flying insects, such as hornets and gnats. The medrash explicitly concludes in favor of Rabbi Yehuda's view - see below for the reasons for this conclusion. [I do not know why, but every non-Jewish website which comes up in a search for the 'Ten Plagues' lists the fourth plague as flies, or something similar to that, basically following Rabbi Nechemia.]
Maskil L'dovid explains Rashi. Rashi first must establish that the meaning of arov follows Rabbi Yehuda (wild animals). However, Rabbi Yehuda's view raises another question. The first three plagues - blood, frogs, lice - were extremely annoying but not life threatening for their duration. The fourth plague, too, according to Rabbi Nechemia, was annoying but not life threatening (flying insects). However, according to Rabbi Yehuda, the fourth plague was life threatening. So according to Rabbi Yehuda we must ask why the fourth plague introduced a life threatening punishment. Accordingly, Rashi first quotes the medrash which follows the view of Rabbi Yehuda (wild animals). Then, immediately and in response to the question of why a life threatening plague is introduced at this stage, Rashi also quotes the Tanchuma which provides the military analogy for the order of the plagues and explains that at the fourth stage barbarians are brought in and kill.
[The reason given by the medrash for concluding that Rabbi Yehuda's view of arov (wild animals) is correct is based on a comparison of the psukim of arov with the psukim of the frogs. At the end of the plague of frogs the psukim say that the frogs died (and caused a stench) in Egypt, but at the end of the plague of arov the psukim do not say that the arov died in Egypt; it merely says the arov was removed from Egypt. If arov means flying insects then why would there be different treatment for the arov at the end of the plague - the arov also could have died and caused a stench in Egypt, like the frogs. However, if arov means wild animals, it is understandable why, unlike the frogs, the arov were removed from Egypt but did not die in Egypt, as dead animal carcasses would have been very valuable to the Egyptians. See Rashi to 8:27. ]