Oh boy. Keywords are a frequent topic here and can be problematic.
Let's start with the way keywords are saved in a file. There are numerous "namespaces" in XMP/EXIF/IPTC (where file metadata is stored) and multiple namespaces where keywords can be stored. Keywords are always just plain text, optionally with delimiters which can be used as nested/heirarchical keywords.
Secondly, ISO standards are a bit muddled as to how they are actually written to and read from a file. An image viewer can either add keywords to the end of an existing list or can rewrite the entire list when changes are made. A viewer can also read and display them in whatever order it decides. Many if not most viewers will keep keywords in alphabetical order.
Don't rely on Lightroom to show you how keywords are actually written in a file, you'd want to use EXIFtool (command line metadata app) which can show you all of the namespaces and how keywords are written to them.
Adobe has made an effort to deal with the "OMG my keywords have to be in order" problem by adding yet another namespace to the list, which has limited ordering functionality.
Please see this thread for a lot more info:
https://community.adobe.com/t5/lightroom-classic-ideas/p-custom-sort-order-of-keywords-instead-of-alphabetic/idc-p/12526371/page/5#M13291