Firstly, they used it to refer to the sky within the earth's atmosphere - as in Genesis 7, when God told Noah to take the different birds of the air (shamayim) onto the Ark with him.
Secondly, they used it to refer to space, where the planets and stars are - as when God told Abraham in Genesis 15 to look to the heaven (shamayim) and count the stars if he could; or like when the writer of Psalm 8 exclaims, "When I consider the heavens (shamayim), the work of your fingers, the moon and the stars that you set in place, what is man, that you would think about him?"
Thirdly, they used it to refer to the dwelling place of God and the angels - as when we read in Psalm 103: 19 that God has established His throne in heaven (shamayim). In different places throughout the Old Testament, we read that God watches mankind from heaven, or hears their prayers from heaven; that's the third meaning of shamayim.
All three understandings appear over and over again in the scriptures, and the intended meaning is always clear from the context. When the psalmist wrote that the heavens declare the glory of God, he was speaking about the sky and the beauty of creation. (Psalm 19: 1) When Ezekiel shared a prophetic picture in which the "birds of the heavens" build nests in a big tree (Ezekiel 31: 6), he was obviously referring to something happening here on earth.
However the arrogance of the people in Genesis 11 was that they thought they could build a tower that would allow them to ascend to heaven, the dwelling place of God. And Lucifer's sin in Isaiah 14: 13 was that he wanted to set up his own throne in heaven, the place where God's throne had been established for all eternity.
Nonetheless, the Israelites sometimes made it doubly clear when they were referring to the third meaning of shamayim. In a dozen or more places they called God's dwelling place, the heaven of heavens. We don't always see this in our English translations, where it simply says that God lives in heaven, or perhaps in "highest heaven," but the Hebrew is more explicit. For example, Moses says in Deut 10: 14 that, "The heavens (shamayim) and the heaven (shamayim) of heavens (shamayim) belong to the Lord." When Solomon was dedicating the new temple in Jerusalem, he acknowledged that no building could contain the Lord because heaven, even the heaven of heavens cannot contain Him. (1 Kings 8: 27)
So when the Hebrews spoke of El Shamayim or Yahweh Shamayim, they weren't speaking of some distant God who lived in an intangible place far away; they were recognising that He was Lord over everything and everywhere: Lord of the earth, Lord of the sky, and Lord of the heavenly realms. Perhaps this is also why some of the psalmists write that God is "exalted above the heavens." They're acknowledging that He is Lord far beyond the boundaries of our galaxy. His throne is outside and above all that is known to us; He is truly the Lord of the universe.
Psalm 123 begins, "I lift up my eyes to you who dwell in the heavens."
This understanding continues into the New Testament. Jesus taught us to pray, "Our Father in heaven... " (Matt 6: 9) The Greek word is οὐρανός - ouranos. While the Old Testament believers often prayed to El Shamayim - God of Heaven, we in the new covenant era often pray to Patēr Ouranos - Heavenly Father. It's our privilege to know Him as Father; spiritually speaking we even have the honour of being seated with Him in heavenly places (epouranios - Eph 2: 6) - but He is still the God of the entire universe and the "heaven of heavens."
The God of Heaven is already enthroned over everything that exists. He deserves also to be Lord over our finances, our relationships, our schedules, our values and our decisions about the future.