Does it make sense to convert a single dummy variable into a factor? I have an R lecture script infront of me, where we are using logistic regression to try to predict the probability that an observation belongs to the target class (e.g. y_i = 1) or not (e.g. y_i = 0). Hence Y is given as a vector of 0's and 1's.
Before running the regression our Prof. turns Y into a factor, but I don't really understand why. Does this have any influence on the accuracy of the prediction? Do all dummy variables have to be turned into factors before they can be used in a ML model?

If a logistic regression model is being used, there will be no difference at all in performance between modeling Y as a factor or Y as an integer. It's possible that setting Y as a factor will change which class is being predicted (switch from predicting 0s to predicting 1s) so coefficients may be different, but as long as evaluation accounts for this, the performance will be the same.
I do know that in some kinds of models (for example, randomForest::randomForest()) turning Y into a factor tells the model to treat the task as a classification task rather than a regression. Perhaps your professor turned Y into a factor to ensure consistency in evaluation between different models.
Treating y as a factor vs numeric variable is a separate issue from treating one of your features/covariates as a factor vs numeric variable. If you have a feature containing just 1s/0s, there will be identical performance regardless of whether you treat that feature as a factor or not. But, if a feature has 1s, 0s, and 2s, the function will create a different feature matrix (and will have different performance) if you treat the feature as a factor because it will create a dummy variables for 1s and 2s prior to running the model.
