How does the laser know where to create the image in the glass?

The laser is focused in the same way a sun's ray can be concentrated by a magnifying glass to set paper on fire.