How to stop wordpress from showing the selected category on top of others in the category selection?

If I got this right, you need this plugin: Category Checklist Tree.

On the post editing screen, after saving a post, you will notice that
the checked categories are displayed on top, breaking the category
hierarchy. This plugin removes that “feature”.

Additionally, it automatically scrolls to the first checked category.

Works with custom taxonomies too.