In Mark 9, John tells Jesus that he and the other disciples stopped a man casting out demons in His name because the man was not following Jesus like they were. Jesus replies that they should have just let him carry on because as long he was not working against them, he is on the same side as them (V.38-40) You see, not everyone that casts out demons is a prophet. Jesus said such people may call him Lord, prophesy or do many wonderful works but He will deny them because they only hear His words but do not do them; they do not follow Him (Matt.7:22-24).
These are false prophets who look like sheep but are wolves inside. The way to recognise a prophet is by the fruits they produce; not whether they speak in tongues, prophecy or cast out demons. You see, the children of God receive the seed of promise of the Holy Spirit by faith to produce fruits. Good seeds produce good fruits and corrupt seeds produce evil fruits (Matt.7:15-20; Rom.9:7-9; Rom.4:13; Eph.1:13). The 12 fruits of the Holy Spirit including righteousness, truth and holiness (Eph.5:9; Rom.6:22) should be evident in the life of a prophet.
Even if a prophet has ever given a word, sign or wonder that comes to pass, it does not mean he will never err. The Lord may use the prophet’s error to test us; whether we follow God or listen to the prophet (Deut.13:1-4) God can use anyone for His purposes, even a non-believer (Jer.43:10). As all gifts and callings are irrevocable (Rom.11:29) and those who believe can cast out demons (Mk.16:17), any supernatural or spiritual demonstration does not indicate a prophet or follower of Jesus.
Both good and corrupt seeds will grow together until harvest time for without the corrupt seeds, the good seeds will not be apparent (Matt.13:30; 1Cor.11:19). But we really ought to be more concerned with our own walk with God rather than judge who might be a false prophet for the Lord knows who are His and the heart of those who are towards Him (1Cor.4:5; 2Tim.2:19). A prophet, like everyone else, is still being sanctified (2Tim.2:21) and we should all be working out our salvation with holy fear and reverence (Phil.2:12) until the day of judgement.