After consulting the materialui documentation (https://material-ui.com/guides/server-rendering/), I was able to find a solution, but I am still unsure of the underlying reason.
Why does the style work initially during rendering but disappear upon subsequent renderings? According to SSR, the CSS is supposed to be included in the html template delivered to the client with each request, so theoretically, the style should remain.
The documentation mentions that "On the client side, the CSS will be injected a second time before removing the server-side injected CSS." However, it is unclear why this removal process is necessary. The CSS is already injected into the html template for each request, so it shouldn't lead to any crashes in theory. Why, then, does the style vanish once the injected CSS is removed?