Demon activity was rampant in the Roman Empire, at this time. They operate in the spirit realm and they function by controlling the bodies of the people they invade. But God is in control in the spiritual realm, and He can control demons.
Mark 1:21-28, Luke 4:31-37
Sabbath, Capernaum, Sabbath Day, Unclean Spirits, Jesus Rebuked Him