Qt uses a GUI event loop to handle events, and update the UI. Any updates to the GUI won't be visible until control is handed over to the event loop and that update is picked up and processed.
The code you write in Python happens in the same thread as the GUI. So while your code is running, the event loop is not, and changes are not being processed.
Side note: this is why your application can 'hang' if you try and do something long-running like accessing an API, without using a separate thread.
In your code, you're setting the current index to 0, then using Python time.sleep() to wait, before updating to index 1.
self.stackedWidget.setCurrentIndex(0)
time.sleep(3) # no event loop running here
self.stackedWidget.setCurrentIndex(1)
While the time.sleep(3) is happening, the execution is held at this point. This means control is not handed back to the Qt event loop, and the first change is not processed. Once the timeout completes, the second index is set, and only then your function returns control back to Qt.
The event loop now applies both changes, but immediately one after another. So all you see is index being set to 1, without first showing 0 and without any delay.
To avoid this, you need to return control back to the event loop after setting the initial index. The simplest way to do this is to just set it, and then trigger the subsequent update using an asynchronous QTimer.
self.stackedWidget.setCurrentIndex(0)
QTimer.singleShot(3000, lambda: self.stackedWidget.setCurrentIndex(1))
The lambda: is used as an anonymous function, so we can pass 1 to setCurrentIndex by delaying execution until the timer is triggered. If you're only ever jumping to a single page you could do this instead:
def go_to_page_1(self):
self.stackedWidget.setCurrentIndex(1)
self.stackedWidget.setCurrentIndex(0)
QTimer.singleShot(3000, go_to_page_1)