When calculating the sample covariance, why do we divide by $n-1$ instead of $n-2$? Don't we lose two degrees of freedom since we need to calculate two sample means? For example, when estimating the variance for a Bayes classifier, we divide by $n-K$ where $K$ is the number of classes since we use $K$ sample means in the calculation.

Could someone please explain this in terms of degrees of freedom?