I got the same error Microsoft SharePoint Server 2013 encountered an error during setup,
In my casesituation, the root cause was because of usingunderlying issue stemmed from utilizing only onea single processor core for my Hyper - V to installV setup when installing SharePoint that should be more than one so I followed the mentioned steps here to increase it , Hope this help you.
For more details, Please check Microsoft SharePoint Server 2016 encountered an error during setup