... or that Samuel wrote Samuel or that Ezra wrote Ezra?
Think about it, these books are about these people. They don't read like, "I did this," "I did that," "I said that." They read, "Joshua did this," "Ezra did that," "Samuel said that." In the case of Samuel, the book of Samuel in Hebrew (it's only one book in Hebrew) extends to the death of David, long after the death of Samuel.
Could God have inspired him to write about all those future events? Sure, but why would we even think anything like that? There's no reason to think that. It doesn't say that Samuel wrote it... anywhere!
It is understandable that people argue over the Mosaic authorship of the Pentateuch or of the Davidic authorship of many psalms or of the Isaianic authorship of the later chapters of Isaiah. After all, there are New Testament passages that seem to refer to Moses or David or Isaiah as their authors.
But there are no New Testament passages that refer to Joshua as the author of Joshua or Samuel as the author of Samuel. We are free to take them exactly as they seem to be--historical narratives written some time after the people they talk about had passed from the scene.