Microscopic theory of quantum anomalous Hall effect in graphene