Dust is just small grains of particulate matter, and all matter is subject to gravity
Every object in the solar system originally formed from a gas and dust cloud condensing due to gravity.
In the case of large planetary bodies like Earth, gravity became sufficient that these small grains accumulated into a solid mass, while the gases became an atmosphere. There are still parts of the Earth's surface though (deserts) where dust is a predominating feature, though it's mostly there because of erosion of rocky material, it's not the primordial dust. A fair bit gets into the atmosphere too during events like sandstorms, but it can't escape Earth, the gravity is too strong.
On Mars dust is a predominant feature nearly everywhere on the surface.
Some dust from the primordial cloud still is out there in interplanetary space though, and some of it continues to be accumulated by Earth and other bodies. The larger grains are sometimes visible when falling to Earth as micrometoerites.
Smaller bodies like comets have very little gravity and are not very solid to begin with, they easily lose material when near the Sun (the comets tail) or may completely disintegrate when perturbed by another very large gravity field like Jupiter. Much of the dust gets returned to the mostly empty space from which it came.
The simplest answer to your question is that the dust is there because it's a principal component of what formed the comet to begin with, the other major one being water ice.
Comets have been appropriately described a 'dirty snowballs'.