The most common issues are an issue with some third party software, or a failing hard drive, or for the 13" model the SATA Hard Drive Flex Cable which has an extremely high rate of failure on the 13" non-Retina model. If it is a 15" model, then a GPU failure is also a possibility.
You can try running the Apple Diagnostics to see if any hardware issues are detected. Only a failing diagnostic result is useful. Unfortunately many of these 2012 Macs are unable to boot to the Apple Diagnostics due to a firmware & boot loader compatibility issue Apple introduced and never fixed.
Try booting into Safe Mode to see if that works. If so, then the issue may be due to third party installed software, but it could still be a failing Hard Drive if one of the drivers blocked by Safe Mode happens to reside on the bad section of the drive which is not being accessed in Safe Mode.
You can try going through Apple's troubleshooting steps for boot issues:
If your Mac doesn't start up all the way - Apple Support
It is possible to check the health of the Hard Drive by creating a booting from a bootable Knoppix Linux USB stick....I can provide instructions if interested. Another option is to install macOS to an external USB drive & see if you can boot from the external drive. If so, then you can use DriveDx (free trial period) to check the health of the internal Hard Drive. Sometimes the health reports for the Hard Drive can show whether the internal SATA HD Flex Cable is at fault. No matter what, if the system boots fine from external media, then it most likely means the fault is with the internal drive (drive itself, cable, file system corruption, software issue).
FYI, it is highly unlikely to be the battery.