That's one of the goals. I wouldn't say it's the goal.
I would argue that the goal of any software should be to help the immediate user. If it is not, then why should the user continue using it?
Stackoverflow is successful because helping the immediate user has secondary benefits, namely that it also helps others. But that doesn't mean this secondary benefit should override the primary goal.
That's like saying "I as the immediate user of Wikipedia want to be able to upload my research paper and have it check if there are any mistakes in my citations. If Wikipedia can't serve that immediate need, why should I continue using it?"
Yet even if Wikipedia isn't good at auto-checking your homework, it's still immensely useful for the vast majority of other users who don't care about auto-checking homework.
You can't build software that satisfies everyone's requirements. It's okay if some users choose not to use your software because it doesn't fulfill their requirements.
StackOverflow is a Q&A site. Asking questions and receiving useful answers is the primary goal, and therefore the immediate users are the askers.
Ultra specific homework questions do not help the immediate users (readers) at all which is why it is frowned upon.
Stack Overflow isn't a free tutoring service, it's a collaborative wiki of answers to common programming questions.
That being said, I agree that the current culture of "you're doing it wrong" is toxic, and should be replaced with a culture of "here's how to do it right".