The bodies and souls of the dead can be bound to the mortal plane; and once they have been bound, they remain. This may be done to provide guards for a tomb or treasure trove; before the Sixth House crisis and the Ghostfence, Dunmer would do this to the more worthless of their ancestors, in the hope that they may serve after death when they served not in life. Since they surely did not invent the custom out of thin air but more likely got it from their ancestors, it's not unreasonable that the Ayleids would have done the same.
That would make sense if the the point in time was much earlier, but these are random adventurers going dungeon diving, and once dead, turn into zombies or spirits shortly afterwards. I want to know why they do so particularly in Ayleid ruins or old, abandoned forts. If there are curses put there, how did they know people are going to plunder the place, or even if it would exist shortly after the Elves' dissappearance?