There is no specific rule against homework. Homework questions are just like any other questions so they should not be judged any differently.
- Is the question on-topic? If not, vote to close.
- Is the question just asking for links to tools, tutorials, or other external resources? If so, then vote to close.
- Is the question clear and does it provide all of the relevant information to solve? If not, vote to close.
- Is the question reasonably scoped that won't require a novel to answer? If not, vote to close.
- Is the question so localized that will never be useful to anyone else (except maybe those taking the same class)? If so, vote to close.
- Is the question just asking for opinions? If so, vote to close.
But if the question is answerable, useful, and it is clear what the issue is, then it shouldn't be closed. Homework doesn't make it an exception to the on-topic/off-topic guidance.
So if you decide it doesn't meet one of the close reasons, then it doesn't need to be closed, but you can downvote it if you don't think it is a useful question or was not well researched, or you can upvote it if you do think it is useful. And you can also choose to answer it or not.
Obviously, the moderator who answered that question did not feel the question should be closed, which is entirely their right (given their binding vote, they could have closed the question immediately), and thought it was worth answering.
No one can explain their rationale except for them, but since there isn't a specific rule against answering homework questions just because they are homework, then they didn't do anything against the rules.
Personally, I don't think it is a really great question, but there are certainly worse questions on the site.
Questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it.
?