At the end of Army of Darkness, after Ash uses the potion and returns to his own time line, he is attacked by a demon at S-Mart. How did that work? Did it follow him from the middle ages, or?
It is never explicitly stated, but there are several likely causes.
In Army of Darkness, Ash misread the Words before picking up the Necronomicon. That triggered the awakening of the titular army. While the army of deadites was defeated in battle, it seems possible that not all of them were exterminated.
Ash traveling back in time and releasing the Army of Darkness may have altered the present time by changing history.
It is worth noting that deadites were free in the world before Ash released the Army of Darkness, and even before Ash arrived in the past. However, they were apparently not present in the time line of Evil Dead 2 until Professor Knowby releases them by reciting from the Necronomicon.
Another possibility is that Annie simply did not succeed in returning all of them to the past in Evil Dead 2.
The deadites and possessing spirits were "returned" through the portal by the incantation from the recovered pages of the Necronomicon. However, this portal acted as a sort of "super vacuum", sucking up everything nearby. Since it was earlier indicated that the possessing spirits were roaming throughout the area, and not just in the cabin (as witnessed by Ash's attack and subsequent possession as he ran/got propelled through the woods), it is possible that not all of the deadites and possessing spirits were close enough to be "sucked up", leaving some to roam free.
A third possibility is that something has changed Ash to make him a magnet for deadites. Perhaps it was the repeated possession (his hand, the full possession that occurred in the cabin until he fought it off, and the "evil twin" episode), or the time travel, or the curse of the Necronomicon, or even a side effect of the potion he used to return to the future.
The most likely by far, though, is that he simply messed up the words (again!) when taking the potion to return to the future, and this allows some of the deadites to travel with him to the future.
One of his co-workers in S-Mart even asks him whether he got the words right when taking the potion, and Ash says:
Ash: Well, maybe I didn't say every single tiny little syllable, no, but basically I said them, yeah... basically.
The existence of the Director's Cut alternate ending is a stronger demonstration of the idea that Ash messes up his return home, although in that version he simply miscounted the drops of the potion he took.
I always felt that the implication was that Ash messed up the spell to retrieve the Necromnicon, and again when travelling back to the present - and so he returned to a future(present) where the Deadites had simply always already been.
Ash: Klaatu Barada N... Necktie... Neckturn... Nickel... It's an "N" word, it's definitely an "N" word! Klaatu... Barada... N... [coughs]
Ash: [pause] Okay... that's it!