For those of you who have tried all the above without success the next thing to try after a factory reset attempt fails is to reflash your stock ROM. [https://www.naldotech.com/samsung-galaxy-a51-bricked-bootloop/|this page] explains the steps to take in attempting to fix the problem (as set forth already in previous answers) then links you to this [https://www.naldotech.com/samsung-galaxy-a51-flash-stock-firmware/|page] which explains how to do it. It is essential that you get the correct ROM for your device by exact model, country and carrier. (You can get the ROM from Samsung, or often from your carrier's website. Google is your frienemy. Be sure you get the ROM from a trustworthy source.) If any of those are wrong things will go badly. Be sure you have the correct ROM, understand the instructions fully and VERY desirable, fully charged device and UPS, you DO NOT want to lose power while doing this! Good luck!