LO and M$ Office are based on different (and sometimes conflicting) underlying concepts.Saving in .docx format means translating some properties into approximate supposed-equivalent ones in the target non-native format.
Document is correct before closing because you work on internal (memory) representation. When saved, this representation is translated into a formatted expression of your document. .odt is the native LO format and is guaranteed to preserve all properties/attributes/highlighting you put on your text.
On the contrary, .docx is adapted to M$ Word concepts which do not encompass all possibilities offered by LO (I refer particularly to the various style layers which have no so universal equivalents). Consequently, some attributes will be lost in the conversion. When you reopen the file, you open in fact a M$ Word document (even if it was previously created with LO Writer) and what was lost is lost for ever.
To circumvent this problem, think over your workflow. Why do you save in .docx? Is this because of collaborative work?
-
If this is not the case, save as .odt. You’ll retrieve all your formatting next time.
-
If you exchange your document with M$ Word aficionados, save as .odt. Since at least 2009, Word can indeed open .docx files. Let the blame of translation be put now on the Word (dark) side and keep your original document as a reference.
If this answer helped you, please accept it by clicking the check mark to the left and, karma permitting, upvote it. If this resolves your problem, close the question, that will help other people with the same question.