We need to read this very carefully in the light of what was happening between Israel and Philistia - a war!
Note that the word for "wilderness" in 1 Sam 4:8 is מִדְבָּר which is the same word used in Ex 13:20 at Succoth at the Red sea where the Egyptian army drowned.
Now, while there are two sets of events here: (1) the plagues on the Egyptians which occurred before the Israelites entered the wilderness, and, (2) the drowning and complete defeat of the Egyptian army in the wilderness which in the heat of the Philistine minds were melded together. Possibly because this was a war, the drowning of an army might figure more significantly in their minds which may explain the use of "wilderness" to include the plagues.
Benson adds another dimension:
That smote the Egyptians in the wilderness — They seem to have had but
a very imperfect and incorrect knowledge of the Israelitish affairs,
and to have supposed that all those plagues which are recorded in
their history had fallen on the Egyptians while the Israelites were in
the wilderness, where they were when the last of these plagues befell
them, and they were drowned in the Red sea. But it is not strange that
these heathen should mistake some circumstances relating to the
affairs of another people, with whom they had no friendly intercourse,
but were in a state of almost continual hostility, especially as some
hundreds of years had now elapsed since these events had taken place.
Gill reaches a similar conclusion:
these are the gods that smote the Egyptians with all the plagues in
the wilderness: the ten plagues were inflicted on the Egyptians in the
land of Egypt, and not in the wilderness; wherefore the Philistines
may be supposed to be mistaken in this circumstance; which is not to
be wondered at, since many historians who have written of the affairs
of the Jews have been mistaken in them, as Justin, Tacitus, and
others; nay, even Josephus himself in some things: but perhaps respect
is had to the drowning of Pharaoh and his host in the Red sea, which
had the wilderness of Etham on both sides of it; and this stroke was
the finishing one of the plagues on the Egyptians. R. Joseph Kimchi
supposes the word for wilderness has the signification of speech, as
in Sol 4:3 and that the sense of the Philistines is, that God smote
the Egyptians with all the plagues he did by his word, his orders, and
commands; but now he was come in person, and would smite them by
himself; this sense Abarbinel calls a beautiful one.