This Dr. Becky video describes the early history of the solar system. Why the Earth exists because of Saturn | Migration of Planets.
In it she talks about how a cloud of nanometer to centimeter sized debris slowly clumped into kilometer sized planetesimals. Computer simulations show a runaway collision process built up planets from there. A short simulation is shown about 2 minutes in. And right away I have questions.
It appears the asteroids are separated by roughly 20x their diameter. Is this realistic? Did the early solar system have enough material to make a disk that dense?
If not, how did a runaway collision process work? Two asteroids nearly on a collision course do not collide. The smaller one is flung away by a gravitational slingshot.
Are these collisions violent or gentle? You can see what looks like both in the simulation. In later stages, violent near collisions are how the Oort cloud formed. The large planets pretty much cleaned out the solar system this way. I would think early stages must have had its share of violent near misses and collisions. Violent collisions would break apart planetesimals.
But many asteroids today are rubble piles. The majority of asteroids in the JPL Small-Body Satellites page are binaries. See What is the smallest known gravitationally bound system?. This implies that these asteroids never experienced a violent collision. Instead they were build from a series of gentle collisions. Given escape velocities of a few meters per second, they must have been very gentle.
So how did this work, given that asteroids that fly by Earth do so at kilometers per second?
From g s's comment, triboelectricity is important. Interesting. I would not have guessed that
The Wikipedia article Triboelectric effect has a reference to this paywalled paper. The Growth Mechanisms of Macroscopic Bodies in Protoplanetary Disks
The abstract says
The formation of planetesimals, the kilometer-sized planetary precursors, is still a puzzling process. Considerable progress has been made over the past years in the physical description of the first stages of planetesimal formation, owing to extensive laboratory work. This review examines the experimental achievements and puts them into the context of the dust processes in protoplanetary disks. It has become clear that planetesimal formation starts with the growth of fractal dust aggregates, followed by compaction processes. As the dust-aggregate sizes increase, the mean collision velocity also increases, leading to the stalling of the growth and possibly to fragmentation, once the dust aggregates have reached decimeter sizes. A multitude of hypotheses for the further growth have been proposed, such as very sticky materials, secondary collision processes, enhanced growth at the snow line, or cumulative dust effects with gravitational instability. We will also critically review these ideas.
So I guess it is still an open question.