Asteroids and similar objects such as Kuiper belt objects and comets, are thought to have been made by a similar slow accretion processes as have the larger planets.
Some of them might be the result of larger protoplanetary objects disintegrating for one reason or another.
The largest such objects, for example Ceres and Pluto, become highly consolidated and potentially could have been seeds for full size planets had there been sufficient extra material available that had not already been accreted into planets, but there wasn't sufficient.
Asteroids start as clumps of dust, that gravity pulls together. But gravity is not strong enough to hold it together, you need something to cause tiny particles to stick together. Particles in space stick together because of static electricity, causing clumps that now look like dusty bunnies. Very very light, but firmly stuck together. Now what happens if you throw a dust bunny at another dust bunny? They might stick or bounce off, but both will end up at a slightly higher density than they were before. The energy of the collision cause the clump to rearrange, getting more and more dense. There is also a lot of metal is asteroids, metal has some strange properties that you don't notice here on earth. If you take a piece of iron and touch it to another piece of iron on earth nothing happens, thats because there is a thin layer of rust covering both objects, in a vacuum though iron will instantly fuse to iron.