A model needs a comparison that is cheap to build and easy to explain. For a numeric outcome, predicting the training mean gives a useful squared-error baseline. For a classification outcome, predicting the training majority class gives a useful accuracy baseline. These models deliberately ignore the input values.
The baseline still has to learn its constant from the training labels. Using test labels to choose that constant contaminates the comparison, even though the estimator has no coefficients. The appropriate baseline also depends on the metric: the mean minimizes squared error, while a median constant minimizes absolute error. These tasks ask for a specific strategy so you can see the difference. A majority classifier can have respectable accuracy while finding none of the positive cases, which the metrics lessons will expose.