Whether it is prior to or after each class the outcome is the same. A 'pure' space is made available for sincere training in a 'way' of personal growth. The surface is free of objects that might cut feet or would be distasteful for contact with one's face when it is placed on the mat. Prior to class it is a metaphor for cleaning away the debris of the day to clear the spirit for a dedicated practice. After class it is an understanding that others are entitled to respect and so a clean area is left for them.
Mirrors are a special case as well.
In Japanese tradition they are a metaphor for the soul. In most dojo you can find them on one or more walls to allow students to examine their posture and technique. Consequently, along with the mat, they should be cleaned daily or at least as often as necessary. Such concern also applies to the spilling of blood on the mat. The shedding of blood is a 'defilement'.