If your smartphone is losing root randomly and you've got tired of rerooting it again, again, and again, you can go through some simple procedures. Firstly, you can use any other rooting method or process except what you're using now. If that won't work, completely reinstall the Magisk, and most probably, you would get freed of that trouble.