Which browser you are using?
If you are using Chrome, it is how the Chrome browser works.
To resolve this issue, add "?web=1" to the end of the URL. Then the document will be opened in the Chrome browser. For example, http://sharepointserver/Shared%20Documents/DateTest.docx?web=1.
For IE and Edge, please follow below tips to troubleshoot.
1.Run this command: Get-SPWOPIBinding | Set-SPWOPIBinding -Defaultaction:$true
2.Go to Site Settings -> Site Collection Features -> Deactivate the feature Open Documents in Client Applications by Default.
3.Go to Document library settings -> Advanced settings -> In the Opening Document in the Browser section, choose Open in the browser.
4.Clear browser cache, then try to open files in the browser.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.