There are three logical options to consider: (1) Mark and Matthew are referring to two separate events; (2) either Matthew or Mark is mistaken in their recollection; (3) Mark focusses on one man, in line with his particular purpose. The first option is unlikely, as both describe an event that took place in the same region with the same effect on a swine-heard. The second option is not acceptable as Matthew (Levi) was an eyewitness to the event, where Mark was recounting this second-hand from Peter’s testimony. The third option is thus the best solution.
2 And when Jesus had stepped out of the boat, immediately there met him out of the tombs a man with an unclean spirit.