Similar failures happen on all platforms, nothing Apple specific here. And discussion if Apple is more or less likely to fail is so old and contentious, it is not productive to rehash it. You may feel your device should run forever and Apple is responsible for it, which is not realistic. Our Microsoft/Dell/... devices at work fail at least as often as Apple. Good luck finding any manufacturer with forever device.
If you have a chance and want to fix this reliably, take it to Apple Store to Genius bar. Support & evaluation is free (at least US, not sure where you are) and they will tell you what they suggest if you give it to them for evaluation. My best guess is they will say hardware failure and offer expensive repair, but some report that they got the device fixed during evaluation itself for free. You would have fixed device with 6 month warranty after they fix it, if it is worth it.
If you are lucky and fix it yourself, you may have potentially unreliable device but "fixed" for free. Obvious steps to do is to run hardware diagnostics and see, if there is obvious major fault. Since it is stalling in installation, sounds like drive issue - so check the drive and if it works well enough, wipe and reformat it, then reinstall system available in recovery, and then upgrade to whatever you feel like to have. If it works, it may run forever or for few days, I went through the drive recovery and got all running for it to fail in week or so catastrophically. This was MBP with soldered SSD, so we ended with Apple replacing mainboard.
Or do what I do... Buy new stuff, return old one for recycling. These are tools for work or entertainment and one needs to budget for possibility of having to replace them after warranty (or extended warranty) expires. It's life, I have learned how to live with it. Makes life easier ;-)