And the Lord said, “Behold, they are one people, and they have all one language, and this is only the beginning of what they will do. And nothing that they propose to do will now be impossible for them. Come, let us go down and there confuse their language, so that they may not understand one another’s speech.” (Genesis 11:6-7)
The simple answer is that we don’t know. All we are told is that originally these people all had one language and afterwards it was confused. Verse 8 says “the Lord dispersed them from there over the face of all the earth”, so it is just possible that God confused the languages by dispersing groups of people to different locations and their language changed over time. However it seems more plausible that the people were dispersed as a consequence of the change in languages and that the confusion of languages was spontaneous.
So let us speculate. God, who can do anything, may simply have changed the brains of these people so that they had different languages. Or he may have changed the circumstances more subtly so that people could just no longer understand each other. The truth is that the Bible doesn’t say so we have no way of knowing.