Spirits are typically thought of as immaterial, supernatural beings that are capable of influencing the material world. And while it's true that some types of spirits are exactly this, the word for spirit is so incredibly broad that it can refer to even that which can only exist if it has a material host and is bound strictly by the capabilities of said host. In these cases, if the material host is destroyed, then the spirit also is destroyed, and ceases to exist. The word in Hebrew is "ruach", and in Greek is "pneuma". These words literally mean "wind".
Wind refers to the physical movement of air. You cannot see the wind, but you can see the effects that it has on some of the things that it interacts with. When the Bible uses the word "wind" to refer to something other than moving air, it can be referring to anything that cannot be seen, but the effects of which can be seen. By this definition, the software that you are using to read this article is also classified as a "spirit" or "wind". Because you cannot see the software, but you can see its effects when it interacts with your monitor.
This word is translated as "breath" in places like Genesis 6:17, where the context is in a creature's ability to breathe. This same word is also found in Genesis 7:22, but some translations skip translating it, since the word "neshema" (literally means "breath") is translated instead. Other translations use "of the spirit" instead. However, since the context is in the creature's ability to breathe, translating this word as "spirit" instead of "wind" or "breath" is actually incorrect. Another example of the word being used in the context of a creature's ability to breathe is Job 34:14-15. Specifically, the context is a person's ability to breathe, and what would happen if this ability was taken away. In this passage, "ruach" is typically translated as "spirit" instead of "wind" or "breath". This may be because the passage describes it as belonging to God.
There are some instances, the word is used to describe someone's state of mind, or their emotional state. For example, Genesis 26:35, where the word is translated as "mind". In Judges 8:3, the word is translated as "anger". And in Genesis 41:8 and 45:27, it's translated as "spirit". In fact, this seems to be the case in a great number of passages where the word is translated as "spirit" when dealing with human "spirits". Just goes to show that you cannot always rely on the translation of Scripture to give you an accurate picture of what's going on.
Along similar lines, in Judges 9:23, Yahweh sends a "spirit of ill" between two groups of people, resulting in a civil war which destroyed both parties, which dealt treacherously with those who had previously rescued them from the Midianites. This "spirit of ill" refers to how the group's relationship with each other went from one of friendship to one of hatred. And in the case of 1 Samuel 16:4, the "distressing spirit" from Yahweh refers to Yahweh turning King Saul into a madman. The "spirit" in this case is referring to the person's character. The word can also refer to someone's motivation or lack thereof. By the way, it is entirely possible that the "Spirit of God" can often refer to God's character, motivation, emotion, etc., and not what is typically thought of as the Spirit of God.
As far as I can tell, the first instance where a spirit is described as being a personal being is 2 Chronicles 18:18-22. This does not by any means, mean that all spirits are personal beings, but this is the first indication that some of them are. Though just because something is personified, does not mean that it's a personal being either. For example, wisdom is personified in Proverbs 1:20 and elsewhere. Also, I'm not counting 1 Samuel 28:13 (King Saul consulting a medium) because the word translated as "spirit" is the Hebrew word "elohim", which literally means "mighty ones", and typically refers to God, or one or more false gods (should be a hint as to what is actually going on in that passage), or a human being who is a ruler or has great influence, strength, or wealth.
When referring to human beings, I cannot find one instance where the spirit is described as an immaterial being controlling a material body. On the contrary, we are described as having spirits, but none of those spirits are described as being "us". Our "spirits" are part of who we are, but can be entirely removed from us and replaced with an entirely different "spirit" (eg: Ezekiel 36:26). These "spirits" represent our character, or the desires of our heart (and yes, the heart is capable of having thoughts and desires). There are very few instances where these spirits are even implied to be immaterial beings.
By the way, that's just the "Old Testament". It's not really until the "New Testament" that we see spirits that are unmistakably described as immaterial beings. That doesn't mean that they didn't exist until the "New Testament" era. We just don't hear of them before then. This in no way means that the nature of human spirits has changed. In fact, the "New Testament" uses the word for spirit in the same way as the "Old Testament" in many places. For example, Mark 2:8, where it refers to Yeshua's state of mind. Or in Luke 8:55, where the intended usage is probably like that of Genesis 6:17, or Job 34:14-15. That is to say, that the girl that Yeshua raised started breathing again. In certain instances, like in Luke 13:11-13, it appears that the "spirit" may be referring to an unseen medical condition that the doctors of the day couldn't figure out, rather than an immaterial being. Actually, the passage outright says it was a sickness, so the "spirit" likely refers to an unseen material cause of the sickness. And it's also the case that it never states in this instance that Yeshua drove anything out.
What about places like John 19:30 or Acts 7:59? The former is using the word like Genesis 6:17, and is likely a newer version of the idiom "he breathed his last" (Genesis 25:8). The latter is probably a reference to Ecclesiastes 12:7, which states that the spirit (referring to the person's breath) returns to God while the person returns to dust. It does not say that the spirit of the righteous returns to God. It says the spirit returns to God, regardless of the righteousness or wickedness of the person. The person who had it returns to dust.
There are two remaining issues concerning the topic of spirits: (1) What is the nature of the Holy Spirit. And (2) can spirits have a physical or defined form (material or otherwise)? Let's start with the second question first, then we'll address the first question.
As mentioned at the beginning of the post, the word translated as "spirit" simply means "wind". And a wind is something that cannot be seen, but has effects that can be seen. So there is no reason, from this definition, that a spirit cannot have a physical (material or otherwise) form. Some will object to this and quote a passage like John 4:24 ("God is a spirit") with Luke 24:39 ("spirits do not have flesh and bones"), asserting that no spirits have any physical form. I touched on this in my post about the Image of God, but didn't go into detail. So let's do exactly that.
A similar instance to Luke 24:39, where the disciples are frightened when they see Yeshua are Matthew 14:26 and Mark 6:49 (Yeshua walking on the water). Now, Matthew and Mark do not use the word "pneuma" to describe what the Disciples thought they saw. They use the word "phantasma", which is where we get the word "phantom" from. "Phantasma" is used to describe a specific type of spirit. In other words: The Disciples thought that they saw a ghost. Luke however, doesn't care about being specific about the type of spirit, though the situation is the same, but in a different setting. So he uses the vague word, "wind", instead. The vagueness of Luke should not be used to nullify the specificity of Matthew and Mark. By the way, the word "phantasma" literally means "to blow". Ghosts also do not exist. Because of this, one cannot say, "the Image of God cannot be literal" just because God is a spirit.
Now, about the nature of the Holy Spirit/Spirit of God. The Bible is actually very vague about this. For example, it never says that the Holy Spirit is God, nor does it ever require you to believe that it is. It also never says that the Holy Spirit is a personal being, though some Scriptures imply that it is while others imply that it is not. Nor does Scripture require us to believe either way concerning that. But there are some places where the "spirit of God" is clearly referring to God's character, desires, or state of mind or emotion. Other than that, it would seem as if God never intended for us to know the nature of his Spirit, and that's assuming that we can even understand it. In fact, 1 Corinthians 2:11 states that we do not know the things of God, implying that we cannot know these things.
To summarize: A human spirit can refer to the person's breath, or the wind of a person's breath. Or it can refer to a person's character, desires, state of emotion, or state of mind. A person is not a spirit, and a person's spirit is not an immaterial being inhabiting a material body. When a person dies (regardless of whether that person is righteous or wicked), the spirit returns to God while the person returns to dust (this is why a bodily resurrection is necessary for Judgement Day or to fulfill the promise of eternal life).
One more thing: Do not conflate "spirits" with "souls". The former is described as something that we have while the latter is described as something that we are (Genesis 2:7). That's a topic for another post.