I created next and previous page buttons, but they are not working

If they don’t work in InDesign, that makes sense - InDesign doesn’t provide that functionality except via the preview capabilities, like the Window menu > Interactive > EPUB Interactivity Preview panel.

If they don’t work in a PDF, that’s different. In InDesign, select the shape being used as a button and go back to the Window menu > Interactivity > Buttons and Forms panel and make sure that the settings are correct, mainly the type, event, and action.