How to find the profit-maximizing output level?

Table 11 In this post, step 5 states the profit-maximizing output level is quantity 5. But in this case, $$p=28$$, $$MC=30$$, $$p\neq MC$$. Why it is the profit-maximizing output level?

Step 4 states the output level where price equals the marginal cost is the output level that maximizes profits. If so, both $$q=4$$ and $$q=5$$, the profit is $$\40$$. Why we don't choose $$q = 4$$ as the profit-maximizing level?

Actually 4 in this case would be completely valid answer since the net profit at both quantity 4 and quantity 5 is equal $$\Pi(q=4)=\Pi(q=5)=40$$. I would even argue 4 is potentially better answer.
In this case the marginal costs at $$q=4$$ are 17 and $$q=5$$ are 30 and 30 is just more closer to 28 than 17. Again, I would not say that necessarily the best answer to discrete problem like this, but my guess is they want to teach to always look at point where price is the closest to MC since in optimum it should be equal.