Are you trying to install SQL fresh OR is this an upgrade of SQL 2012 to SP3? Have you had SQL Server 2012 installed on that machine (and potentially the same folder) before?
Another possible scenario - do you have Edge installed on your machine? Sounds unrelated, but I found this forum post:
Where Edge needed to be installed and that fixed the problem. Mind you, in the case with Edge, that was SQL Server 2019; I don't think SQL Server 2012 knew Edge was a thing.
Last few questions (again probably answered by looking at the logs) - are you using a supported OS for SQL Server 2012? Windows Server 2019 (for example) is not supported for SQL Server 2012. That being said, I've read that it works.
Is your server fully patched? Do you have enough disk space?
And the very last question (which should have been the first, but Grant already mentioned it, so I wasn't trying to just repeat his suggestion) - what is in the logs? The logs will tell you why it failed, what it failed on, and possibly even how to fix it. That's what the logs are for!
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.