Below posts I normally see "share", "edit", and "flag" buttons, but sometimes a "delete" button also appears. How is it decided that this extra button appears?
At the moment you only have the option of deleting posts that you have created. The criteria under which users can delete their own posts is described in the MSE deletion faq:
When can't I delete my own post?
You can't delete answers that have been accepted.
You can't delete any question that:
- has an upvoted answer, or
- has multiple answers (even if there are no upvotes)
You can't delete any of your questions or answers if you haven't registered your account (that is, associated an OpenID with it).
Certain users (as well as ♦-moderators) also have the ability to vote to delete posts of other users. This is also explained in the faq.
If you don't have the ability to (vote to) delete a post, the "delete" button will not appear.