This was perfectly within the rules of Stack Exchange, including the guidance given to moderators.
The closure of a question and the discussion whether it’s on-topic are two independent processes. The closing of a question requires a certain number of close votes, in the case of a moderator vote, one is sufficient. The guidance to moderators is to vote like they would as regular users with non-binding votes. That moderators tend to hold back is a bit of a custom, but by no means required, quite the contrary, in fact. The same principle applies to the reopening process. Neither is irreversible, and that’s part of the way the SE system is designed.
Any discussion whether a question is within the site’s scope and possible clarification can happen at any given time, whether the post is open or closed.
For basic discussions about whether a topic should be within the scope, we have this Meta. In the case of pet food, this decision has already been made by the community. Comments are not the right place.
In short, it’s perfectly acceptable if a question gets closed while a discussion is still ongoing. That it happens infrequently here is usually because we have few users that exercise their right to vote for closing and our mods aren’t around 24/7, so that this kind of debate here often is already competed by the time enough close votes were gathered or problems with the post fixed. On sites with significantly more traffic, the pattern is rather closing first (also to prevent a bad post from gathering worse answers), then reopen after a discussion and/or an edit.
Your claim that the post, that was clearly off-topic as originally posted, had no comment or guidance is incorrect, please refer to the custom close vote in the comment section.