how do I remove nextcloud completely and then install it again?
It seems like there are rests of the old cloud still on the pi creating problems when trying to reinstall the programm.
That’s why you always should document how you are setting a server up.
But maybe in this case it’is better to start from scratch anyways. Write a new and clean Raspian image to your SD-Card. Links on how to do that are in the tutorial you linked.
Then download the tutorial or better copy every relvant step to a doc of your own. Also document any changes or additional things you do during the setup or in the future! It is impossible to remeber every detail or small change you made in a year or two when suddenly a problem occures. Also the guide you used might not be online anymore until then.
Many of the problems users have here in the forums could be avoided, or at least they would be easier to solve, if people did two things: Backups and documentation! I’m saying this becaus I’ve been there.
Because of your link you use NextcloudPi . Perhaps you can use the installation guide here .
I think you use a sh-script and the other guide uses an ISO file and overwrites all.
Perhaps you also can install Raspberry Pi OS ( previously called Raspbian) and use this manual (not tested).