In geometrical optics we have the law of reflection, "angle of reflection equals angle of incidence," we represent the light by rays that refract or reflect when encountering lenses and mirrors and those objects are represented as simple surfaces.
What is actually happening on a microscopic level is complicated and can be described in several ways. I will try to answer you question using physical optics, where light is a wave phenomenon and it interacts with the constituents of matter in the objects causing these to become new radiators of light. As that light is generally random in direction, the OP was asking how the reflected light "knows" to follow the law of reflection.