In 1822, Mary Ann Mantell was accompanying her husband, obstetrician and paleontologist Gideon Mantell, on a visit to a patient, when she noticed something shiny at the side of the road. Looking closer, she found large teeth embedded into the rock.
Her husband Gideon, in a major breakthrough, realized that the fossil belonged to a creature unknown to science, which he would later describe and name Iguanadon after their iguana-like teeth. Later, paleontologist Richard Owen examined a number of fossil sets and concluded that Iguanodon, Megalosaurus, and Hylaeosaurus fossils were from "a distinct tribe or sub-order of Saurian Reptiles" which he termed, rather catchily, "dinosauria".
So that's (roughly) how dinosaurs became recognized for what they were. But these finds were far from humankind's first encounter with dinosaur fossils, which after all had been strewn around the Earth for hundreds of millions of years before any humans even bothered to show up.
Fossils have likely been discovered throughout human history, despite not being recognized for what they are until relatively recently. In fact, a Megalosaurus fossil was found in the mid-1600s, which at first was thought to be like a human femur, before being described by naturalist Robert Plot in 1677 as the bone of an elephant, brought over to England by the Romans. An illustration of the fossil caught the attention of English physician Richard Brookes, who in 1763 named the fossil scrotum humanum, looking at a fossil of an entirely new species of giant monster from millions of years ago and remarking at how it looks a bit like human testicles.
Before we realized what dinosaurs were, discoveries of their bones were often attributed to giant versions of known animals, or giant humans. Long before that, it's been suggested that dinosaur bones inspired the stories of griffins, giants, and dragons.
Ancient Greek legends of griffins nesting near gold mines in the Gobi Desert, according to classical folklorist Adrienne Mayor, could be an attempt by people to explain fossils they had found there. Parts of the Gobi Desert were once home to a large number of fossils, with Protoceratops looking similar enough in appearance to the mythical creature. Fossils of dinosaurs, seen by a Chinese historian in the 4th century BCE, were labeled as dragon bones, while "dragon bones" were prescribed for ailments from madness to diarrhea.
We may not have only been unearthing dinosaur bones for as long as we've been around, we may have been using them as an attempt to cure the runs.