This is an excellent question because of the important point it reveals about spiritual truth. First, let me record that the phrase "Spirit of God" occurs 19 times in the NT and ALWAYS means the Holy Spirit, eg, 1 Cor 12:3.
We have two clear statements of Scripture about people being motivated by the Spirit of God:
- 1 Cor 12:3 - Therefore I inform you that no one who is speaking by the Spirit of God says, “Jesus be cursed,” and no one can say, “Jesus is Lord,” except by the Holy Spirit.
- 1 John 4:1, 2 - Beloved, do not believe every spirit, but test the spirits to see whether they are from God. For many false prophets have gone out into the world. By this you will know the Spirit of God: Every spirit that confesses that Jesus Christ has come in the flesh is from God.
This must be understood in the terms set out in 1 Cor 2:14 -
The natural man does not accept the things that come from the Spirit
of God. For they are foolishness to him, and he cannot understand
them, because they are spiritually discerned.
Therefore, the very reason that people, humans, cannot discern spiritual truth is because we are fallen, sinful humans with "fleshly" minds and bodies. It is precisely for this reason that we need the enlightenment of the Holy Spirit, or, Spirit of God (1 Cor 12:3) to understand the unseen spiritual world. Jesus made the same comment:
John 16:13 - However, when the Spirit of truth comes, He will guide
you into all truth. For He will not speak on His own, but He will
speak what He hears, and He will declare to you what is to come. He
will glorify Me by taking from what is Mine and disclosing it to you.
Now to Mark 2:21-24 and the point of all this. The truths about humans do not necessarily apply to demon spirits which is the subject of Mark 2. Of course spirit beings, whether evil or holy understand spirit things because they are spiritual beings. The demons knew who Jesus was as recorded a few verses earlier in Mark 1:34 -
And He healed many who were ill with various diseases and drove out
many demons. But He would not allow the demons to speak, because they
knew who He was.
James is even more specific:
James 2:19 - You believe that God is one. Good for you! Even the
demons believe that—and shudder.
It is only we fleshly, sinful, fallen humans that need the enlightenment of the Spirit of God to understand spiritual realities - the demon spirits understand these things already.