The Application Preference Order for Markdown files (text/markdown) forces KWrite to be the first or second entry. When apply is clicked with KWrite elsewhere in the list, it is moved to first or second. Only Kate and Okular (okularApplication_md.desktop) can be above KWrite, but only one of them.
I'm seeing something similar; not sure if it's related, but the concept is the same. In my case, KDE keeps putting qpdfview as the default PDF viewer, despite my constantly changing it to Okular. When I set it to Okular, it works for a bit, and then eventually qpdfview is preferred (I suspect it's nothing specific to qpdfview; that just happens to be the one listed at the top). In $HOME/.config/mimeapps.list, Okular is still listed at the top, even when qpdfview is being selected by KDE: > [Added Associations] > application/pdf=okularApplication_pdf.desktop;qpdfview.desktop;org.kde.calligra.karbon.desktop;microsoft-edge.desktop;google-chrome.desktop;brave-browser.desktop;vivaldi-stable.desktop;com.calibre_ebook.calibre.desktop;io.github.zen_browser.zen.desktop;com.calibre_ebook.calibre.ebook-viewer.desktop;org.pwmt.zathura-pdf-mupdf.desktop; So it's not something as simple as that file being surreptitiously changed. I updated to Plasma 6.1.5 on September 11, and Frameworks 6.6.0 on September 18. It *feels* to me like the timing is more correlated with the Frameworks update than Plasma, but I can't be certain (and, there's no guarantee it's from either of those updates anyway).
Looking at the mameapps.list file locally, text/markdown has Ghostwriter first, then KWrite. But Dolphin and keditfiletype keep listing KWrite first. SO it is something in KDE reorganizing the list.
*** This bug has been marked as a duplicate of bug 393700 ***