Unclean spirits can attach themselves to people for a number of reasons. One reason in particular may not be considered too often by believers. It's important to be diligent concerning who your teachers are. An unclean spirit can attach to you because you've received wrong teaching that you thought was correct.
2Corinthians 11:1-4 shows us this truth.
I hope you will put up with me in a little foolishness. Yes, please put up with me! I am jealous for you with a godly jealousy. I promised you to one husband, to Christ, so that I might present you as a pure virgin to him. But I am afraid that just as Eve was deceived by the serpent’s cunning, your minds may somehow be led astray from your sincere and pure devotion to Christ. For if someone comes to you and preaches a Jesus other than the Jesus we preached, or if you receive a different spirit from the Spirit you received, or a different gospel from the one you accepted, you put up with it easily enough. - 2Corinthians 11:1-4