I'm thinking of doing something similar in my daughters room with a full-length mirror. I'm not sure if I'll do that or if I'll paint a nice border all around.
Anyway, I think "they" put the mirror on the wall beforehand using glue. Then they nail the wood to the wall making sure that the nails don't go through and crack the mirror. I don't think I would glue anything to the mirror, just position the wood to frame the mirror and nail the wood into the wall.
Or you can go to Lowes or Home Depot and go over to the book section and peruse the various How To books for a solution!