taking care of the bike, motor, battery, keeping it dry at all costs, and servicing it regularly is your best way to have the highest chance of no failures.
I think you pretty much summed it up!
My philosophy when it comes to choosing and using an ebike has always been about:
1) Selecting a frame design, geometry and material matching my usage needs and riding patterns. Aluminum rear triangle is a must (if everything else is Carbon). Adequate suspension travel, wheelset size, etc.
2) Determining the correct bike size for my build, and have it professionally fitted to my morphology (very important step).
3) Selecting higher-end, quality components. In other words, getting the best parts I can reasonably afford.
4) Requiring a motorization/motor brand that I consider to be superior to others. For me it's the Bosch CX Gen 4 motor (non-smart system) with latest FW and good ol' Purion handlebar-mounted controller. Awesome piece of equipement if you ask me, but YMMV.
5) Opting for an easily removable or detachable battery. A must-have in my book.
6) Then, riding the bike knowing its limitations (and mine!) including avoiding water ingress and humidity in motor, battery, electrical components and bearings.
7) Finally, taking good care of the bike with pre-ride inspections with lub and re-tightening, regular maintenance and service with proactive parts replacement, and basically use common sense and follow best-practices to keep the bike in top shape!
Hope this helps. Good luck with your next eMTB pick!