After you edit to the text area, extract_button
becomes False
and you no longer have a text area nor a download button and nothing is downloaded. You can try something like this instead.
extract_button = st.button("Extract text")
if extract_button:
st.session_state["text"] = "OCR text with a lot of errors and need to edit it "
if "text" in st.session_state:
st.text_area("Output is: ", key="text", height=220)
st.download_button(
label="Download data as docx",
data=st.session_state["text"],
file_name="output.docx",
mime="docx",
)