It’s all to do with the shape of the pelvis. Dinosaurs are divided into two groups: the Saurischia, or lizard-hipped’ dinosaurs, have a pubis bone that points forward; the Ornithischia (‘bird-hipped’) have a backwards-pointing pubis.
Any fossil with either of these pelvis types is classified as a dinosaur. Ironically, birds are actually descended from the Saurischia. Their bird hips evolved independently, much later in time.