I’m not sure if it’s a bug per se. I understand your confusion.
To prevent HTML tags and attributes/classnames from being filtered out, this needs to be explicitly allowed in Discourse core or a plugin.
For example, a default list can be found here:
https://github.com/discourse/discourse/blob/main/app/assets/javascripts/pretty-text/addon/allow-lister.js#L115
It’s also possible to allow a tag for the preview only. For example, the image controls have several tag/class name/attribute combinations.
You see the button in preview because it’s a side effect of the tag that is allowed here.
However, the disabled attribute is ignored because it is not defined.
I did not check how the allowed list is parsed; I wonder if it’s the expected behavior.
. Currently, it seems the tag is allowed regardless of the attributes. I would have expected that the button is not rendered if you are not using exactly, for example, <button class="alt-text-edit-ok btn btn-primary">.
You can make a plugin to allow <button> on post render. Let me know if you need assistance.