Do mods have to follow a hard set of rules, or can they take down anything that they consider inappropriate? Can they take down questions or comments that are relevant to the community just because they don't like them?
The comment in question
The ball is made out of an elastic material, when you hit the ball you compress it so it acts like a spring. When the ball is moving towards you, that kinetic energy helps you to compress the ball even more, and then the energy of that compressed ball is released it flies even further. – user3408085 yesterday
Is not an attempt to improve the answer which—despite the wide variety of comment left every day—we all remember is the only official use-case for comments.
If you want your answer to be safe from arbitrary deletion then put it in a answer-post.
That is all.
To answer your question in general: mostly no, there is not a hard set of rules that we have to follow when it comes to deleting posts. Here I'm taking "hard set of rules" to mean rules that, if broken, would result in disciplinary action against the moderator.1 There are a lot of "soft" rules though - by that I mean there are guidelines which we are expected to use to guide our actions. These guidelines come from a combination of the help center, this meta site, the "mother meta" site, and conversations with other site members, with other moderators, and with the Stack Exchange community team.
When it comes to deletion of posts, there are really three cases:
- Deletion of comments is pretty free, once it seems they have served their purpose. As mentioned on the help center page about the commenting privilege, comments are meant for requesting clarification, suggesting improvement, and adding other minor/transient information. All of these are inherently temporary purposes, and the comments are prone to be deleted once they've been seen and acted on (or declined to be acted on), or if they've been sitting around for a few weeks. We also aggressively delete comments which don't do one of these things, especially those which fall under the list of things you shouldn't do in comments on the same privileges page I linked.
- Deletion of answers is more rare. In general, moderators don't delete answers without a specific reason to do so, such as that the answer didn't actually answer the question, or that it was spam. We have a page in the help center about deleting answers that lists the most common reasons an answer might be deleted; it's very unusual that an answer is deleted for a reason which isn't on that list.
- Deletion of questions is something we actively try to avoid, because deleting a question takes all its answers with it. Some questions get deleted because they are particularly low quality, but that happens automatically, and we (moderators) have found that if we think a question is not worth keeping around, it usually gets taken care of by that automatic process. We have a page in the help center about deleting questions as well which lists some reasons why a question could be deleted.
1The moderator agreement is an example of a hard set of rules in this sense, but it says nothing about when posts can be deleted.