That's a really dated model, might be time to just start shopping around for a new or newer phone.
https://www.devicespecifications.com/en/model/b24c404a
It was a budget-class phone even its day, so compared to even current budget-class phones it's really lacking. It's not just Google that dropped supporting Marshmallow years ago, there's dwindling to no support by third-party developers for the apps you might be using, all on top a inevitable system resource drawbacks on a hardware level. You can continue to waste time trying to repair it and then keep this phone running but I'd recommend you instead start looking forward and just buy a new one.
That boot looping issue you're seeing as your phone is trying to 'optimize' itself is likely to be a sign the installed Android operating system is corrupted in some way. Keep in mind a Factory Reset does not affect the operating system directly, all it involves is wiping the user data partition clean. So since you did do a Factory Reset, that 'optimizing' message you still see is probably a reference to the Android Runtime that's integral to the Android install itself.
https://en.wikipedia.org/wiki/Android_Runtime
If that is the case, in order to reinstall the operating system you need to re-flash the firmware with an appropriate stock ROM. It's not a necessarily difficult thing to do, but it require you to be comfortable doing such things. But again, this is a really dated model so just getting a new phone that you don't have to fight with might work out better.