Let's say, I am making something concrete by putting ideas, thoughts, knowledge into paper. While doing it, I am finding gaps and mistakes and finding opportunities to correct them. But it is not limited to 'correction', it also opens newer dimensions and perspectives- ones that previously didn't exist in my conscious mind.
I consider writing as a tool of thinking. Another tool is brainstorming with a group, or any group discussion in general. These amend to your thoughts, make the existing ones more solid, and opens new direction, and unravels connections previously not accessible.
Read this essay by Paul Graham: Putting Ideas into Words [0]. And also refer to his other essays on writing.
There is also a great book by Paul Zissner: Writing to Learn. I suggest this book to people.
Writing, when done while learning works akin to teaching- one of the most crucial steps in so-called Feynman Technique of learning.