Can anyone explain the difference between glam metal and hard rock? I found songs like Sweet Child o Mine by Guns n' Roses in wikipedia as both glam metal and hard rock but songs like Bohemian Rhapshody by Queen is described only as hard rock.
Any specific answer you're going to get will be entirely arbitrary. You aren't talking about something like Gregorian Chant and Old Roman Chant where you can say the objective differences are X and then start sorting.
Instead, (a) both genres are based on subjective values (b) of entirely separate aspects of the music and presentation. One analogy would be what's the difference between crunchy food and pretty food? Some people say apples are both but others only describe pop tarts as pretty.
Thus saith the Wiki:
Hard rock is a loosely defined subgenre of rock music typified by aggressive vocals and distorted electric guitars.
In other words, rock that sounds angry, powerfully sexy, or angrily and powerfully sexy to the listener but doesn't fall into a more specific category like punk or heavy metal (usually). No costumes (usually). "Good" rock (usually).
Glam metal [aka hair metal or pop metal] is a subgenre of heavy metal that features pop-influenced hooks and guitar riffs, upbeat rock anthems, and slow power ballads.
In other words, almost exactly the same thing but—in the speakers' subjective opinion—kinda sorta closer to heavy metal but y'know also kinda poppy sorta but not pop-poppy but still kinda sorta poppy, y'know? Plus some influence from glam rock (usually). I mean... their hair is longer (usually) and they pay more attention to how they look (usually) and it's less angry angry (usually). Y'know, stuff like [list of arbitrarily assigned bands]. Less necessarily good.
Anyway, 'Sweet Child o' Mine' is just rock or a power ballad. It isn't metal at all even though you could call Guns n Roses a glam metal band if you really want to restrict what you call glam rock. Guns n Roses has hard rock songs but SCoM ain't one of them.
Meanwhile, Queen is just stadium rock or pop rock or queer rock. There's nothing hard about 'Bohemian Rhapsody' at all and I'd just slot it into the same power ballad category as SCoM. That works even if other posters here vehemently disagree, since the divisions for these categories and subcategories are just based on feelings, personal taste, and self-identity ('I'm the kind of person who likes X. Song Y slaps. Therefore Song Y is X.').