If you get errors for exactly the shown code, something with TeXstudio, your document folder or your installation is broken. Please add
\listfiles
(at very first line) to the shown example, copy it to a new folder, open it there and run PDFLaTeX. If this fails again, post the whole log file.
What you could also test:
- In TeXstudio use
Options → Restore Default Settings …
to reset the configuration to the defaults. After this TeXstudio, e.g., would use PDFLaTeX again for Tools → Compile
.
- Update MiKTeX. This can be done, using the MiKTeX Console from the Windows start menu. With the (usual) multi user installation, first do the update in the Administration mode (the MiKTeX Console offers to run in this mode, after starting the MiKTeX Console). Then do it again in User mode (not switching to admin-mode after starting the MiKTeX Console).
And don't forget: Do such tests with minimal documents always in a new folder not in the folder of your real document. And after changing something, always delete all temporary auxiliary files like the aux-file. Otherwise mistakes of prior LaTeX runs that result in errors in the auxiliary files could persist even if the origin has been fixed.