I think you can just go to File>Save As - and then in that dialogue box beside the file name you can choose what file type you want to save it as.
I’m not sure why it would change the default file type from .odt or .docx to .txt, but you want to save the file either as a .odt or .docx type. You can also set the default save type in the preferences menu.
BTW the .docx is the Microsoft word format and .odt is the Open Document Format. They both have the same functionality but the .docx is more commonly used while the .odt is better for long term document storage because it’s an open source file standard.