How does gas and rock merge in a protoplanetary disk? If all the material to make the planet in the same orbit is moving at the same orbital velocity, how can a few pieces of dust group together and form bigger and bigger planetesimals?

Gravity.

Remember that not only does the star exert gravitational force on the debris field but so do the individual elements on each other. I read somewhere once that two baseballs places at arms length apart, call it 3′-4′, would take 3 days to come together from each other’s gravitational force.

As such, the debris field would start to form moats of sand and dust. Those would pull into mushy balls of sand. Eventually, they become big enough that the internal pressure starts welding material together. Bigger and bigger until you get a planet. Composition of materials determines the type of planet. Amount of material determines size.