I created a document in inDesign, exported it to PDF, and then exported the PDF into word. The formatting and style looks fine but my issue is when I try to edit the content in the word document. The spacing gets messed up when you try to replace some pieces of text in the word document. Is there any way to fix this or prevent it from happening in the future?
Word has severe limitations in terms of layout. Layout is not what Word is designed to do. When you export a PDF to Word, Acrobat does it's best to navigate the complexity of issues layout in Word presents. Often configuring things "under-the-hood" in Word to maintain as much of the layout appearance as possible. Acrobat is only concerned with getting the appearance as correct as possible. Acrobat does not assume further editing is necessary, even though it often may be.
There is no reliable route from InDesign to Word to maintain both appearance AND edit-ability which I am aware of. Word is a text editor it is not a layout application and although there are tricks you can pull off and hoops you can jump through to get Word to do some layout-like things, it will never be easy or solid if you then need to edit the Word document further.
The short answer is..... if you need to edit, go back to the InDesign file and edit, then create the PDF and then export to Word again. This generally has to be done for any change.
Word is simply not a stable layout application. Truth of the matter is.. that exported PDF may look great on your system in Word, but chances are VERY high it won't hold up when the .doc/.docx file is opened on any other system. It's a limitation (problem) with Word and there's not a great deal one can do about it.