Your question is best explained in a broader context: What is the difference between "error" and "residual?"

In regression, residuals are calculated based on a fitted model for which the underlying parameters are estimated from the data we observed, because those underlying parameters are unknown to us. For this reason, residuals are not independent: a constraint is imposed on the model fit to make the estimated parameters uniquely determined (as in the case of ordinary least squares fitting in linear regression).

This speaks to a subtle but important property of residuals: they are in a sense estimates or realizations of error conditional on the assumption that the true error is faithfully represented by the data you observed. Error in a model is intended to capture natural random variation of the response (dependent) variable not explained by the predictors (independent variables). But a residual could be calculated from any model fit and it need not be true to this underlying error.