How do we know that dinosaurs were related to lizards and/or birds?
In general the answer is always the same: you construct a phylogenetic tree. In order to locate different species on this tree in relation to each other, you use various features to compare which species are more similar to each other than others.

The best way of doing this is by comparing their DNA sequence, especially orthologous genes (i.e. genes common to the species compared).

Unfortunately, genetic sequences usually aren’t available for extinct species. You can still compare homologous features though. For instance, the class of mammals are all characterised by the possession of mammary glands. Similarly, all vertebrates have a vertebral column and all aves are feathered, warm-blooded, egg-laying vertebrates.

The collection of many such features from fossile records allows the creation of more or less detailed phylogenies. The Wikipedia explanation mentions several transitional fossil forms which trace the evolution from dinosaurs to modern birds via several intermediates. All of the inferences are based on anatomical resemblance.

This may sound weak evidence but in fact anatomical homology has proved to be sufficiently accurate in constructing other phylogenies, where we have been able to verify the correctness using genome comparison data. So while there is much uncertainty about the precise branching point of birds from dinosaurs (or maybe archosaurs), there is near-certainty that the common ancestor of birds and dinosaurs was, in fact, an archosaur.