I think you are discounting there is a supernatural element to all of this. Trying to determine who exactly wrote the books or when is irrelevant. God had the Bible written exactly how he wanted it to be written. Trying to understand logically how everything came to pass is never going to give you all the answers.