All-optical control of spin in a 2D van der Waals magnet