I believe you are missing the fact that chapters 17 through 21 of the book of Judges are out of chronological sequence. According to the time line provided at BibleHub, the incident recorded in Judges 18, concerning the Danites, happened only about 25 years after the land had been allotted to the tribes.
Robert Jamieson says this:
The Danites had a territory assigned them as well as the other tribes. But either through indolence, or a lack of energy, they did not acquire the full possession of their allotment, but suffered a considerable portion of it to be wrested out of their hands by the encroachments of their powerful neighbors, the Philistines. In consequence, being straitened for room, a considerable number resolved on trying to effect a new and additional settlement in a remote part of the land.
-- The Book of Judges, Chapter 18: Commentary by Robert Jamieson
Additional Note
Joshua 23 opens with:
And it came to pass a long time after that the LORD had given rest unto Israel from all their enemies round about, that Joshua waxed old and stricken in age.
And Joshua 24:29 records Joshua's death:
And it came to pass after these things, that Joshua the son of Nun, the servant of the LORD, died, being an hundred and ten years old.
We can be confident, then, that the words of Joshua's last address to the people of Israel occurred just before he died, which means the events of Joshua 23-24 and Judges 18 are happening at much the same time, i.e. around 1375 BC.
Now, during Joshua's last speech he says:
Behold, I have divided unto you by lot these nations that remain, to be an inheritance for your tribes, from Jordan, with all the nations that I have cut off, even unto the great sea westward. And the LORD your God, he shall expel them from before you, and drive them from out of your sight; and ye shall possess their land, as the LORD your God hath promised unto you.
-- Joshua 23:4-5 (KJV)
So, Joshua died before Israel had fulfilled the charge given by God to "go in and possess the land" (Deuteronomy 10:11), and what is recorded in Judges 18 simply gives us a more detailed picture of one part of the action at that time.
Chuck Smith refers to Judges 17 through 21 as an appendix to the Book of Judges.