Captivity is a very central theme in both the Old Testament and the Book of Mormon. Searching for that particular word gives 163 results in those two volumes of scripture combined and 4 results in the rest of the standard works! No wonder, perhaps, considering the captivity in Egypt between Abraham and Moses, when the covenant people of Israel was established, as well as the Babylonian captivity after they had broken the covenant in the promised land. Jeremiah in particular talks about it a lot. He prophesied of the Babylonian captivity but also the later escape and restoration of the Jews.
Lehi was a contemporary with Jeremiah. With the imminent Babylonian captivity as backdrop, there is no wonder that this is an important theme in the Book of Mormon too. Lehi prophecied
That after they should be destroyed, even that great city , and many be captive into , according to the own due time of the Lord, they should again, yea, even be brought back out of captivity; and after they should be brought back out of captivity they should possess again the land of their inheritance. (1 Nephi 10:3)
Similar to Jeremiah
And I will be found of you, saith the Lord: and I will turn away your captivity, and I will you from all the nations, and from all the places whither I have driven you, saith the Lord; and I will bring you again into the place whence I caused you to be carried away captive. (Jeremiah 29:14)
It is a theme repeated time and again in the Book of Mormon, not only in remembrance of their father Lehi who escaped the Babylonian captivity. Nephi reminds his brothers of the Egyptian captivity and escape
Therefore let us go up; let us be like unto Moses; for he truly spake unto the waters of the and they divided hither and thither, and our fathers came through, out of captivity, on dry ground, and the armies of Pharaoh did follow and were drowned in the waters of the Red Sea. (1 Nephi 4:2)
The reminder of the Egyptian captivity is repeated in the next chapter (see 1 Nephi 5:15). Eventually, the Nephites get their own captivity and escape narratives to commemorate, for instance the parallel stories of Limhi's people and Alma's people. Remembering this captivity becomes vital and is even commanded by an angel, as previously written in this post.
A peculiar addition to the captivity focus of the Book of Mormon is the Jaredite history with lots of kings living in captivity for much or all of their lives. Perhaps an expression of the Jaredite's failure to comply with the special conditions of the promised land.
Behold, this is a choice land, and whatsoever nation shall possess it shall be from bondage, and from captivity, and from all other nations under heaven, if they will but the God of the land, who is Jesus Christ, who hath been manifested by the things which we have written. (Ether 2:12)
But as mentioned before, the Book of Mormon tends to use physical phenomena and apply them spiritually. The physical captivity of their fathers becomes an analogy of the captivity of the devil. Or perhaps it is even regarded as more or less one and the same. It is interesting to note the transitions between physical and spiritual captivity in the Book of Mormon. For instance, in 2 Nephi 1, Lehi talks to his sons and repeats the promises and conditions that the Lord gave to the Jaredites
Wherefore, this is consecrated unto him whom he shall bring. And if it so be that they shall serve him according to the commandments which he hath given, it shall be a land of unto them; wherefore, they shall never be brought down into captivity; if so, it shall be because of iniquity; for if iniquity shall abound shall be the land for their sakes, but unto the righteous it shall be blessed forever. (2 Nephi 1:7)
Only a few verses later, he speaks of the captivity of the devil
Or, that a should come upon you for the space of ; and ye are visited by sword, and by famine, and are hated, and are led according to the will and captivity of the . (2 Nephi 1:18)
It's not even easy to determine whether he talks about physical or spiritual captivity in this verse. Sword and famine are physical and "captivity of the devil" is added in that context. They go hand in hand. The same thing happens again when Lehi speaks to his son, Joseph, only two chapters later
4 For behold, thou art the fruit of my loins; and I am a descendant of who was carried into Egypt. And great were the of the Lord which he made unto Joseph.
5 Wherefore, Joseph truly our day. And he obtained a of the Lord, that out of the fruit of his loins the Lord God would raise up a unto the house of Israel; not the Messiah, but a branch which was to be broken off, nevertheless, to be remembered in the covenants of the Lord that the Messiah should be made unto them in the latter days, in the spirit of power, unto the bringing of them out of unto light—yea, out of hidden darkness and out of captivity unto freedom. (2 Nephi 3)
First a reminder of Joseph's (physical) captivity in Egypt. Then a prophecy of his descendant's escape out of darkness and (spiritual) captivity.
One final example from Alma:
5 And behold, after that, they were brought into by the hands of the Lamanites in the wilderness; yea, I say unto you, they were in captivity, and again the Lord did deliver them out of by the power of his word; and we were brought into this land, and here we began to establish the church of God throughout this land also.
6 And now behold, I say unto you, my brethren, you that belong to this church, have you sufficiently retained in the captivity of your fathers? Yea, and have you sufficiently retained in remembrance his mercy and long-suffering towards them? And moreover, have ye sufficiently retained in remembrance that he has their souls from hell? (Alma 5)
God delivered their fathers out of physical captivity and bondage. He also delivered their souls from hell. Whatever type of captivity, God has the power to deliver. This is an important message from Nephite prophets.