I've easily lost a dozen or so fish over the past 2-3 years. That's not counting the ones from "back in the day" when cycling was unheard of and hornwort was just about the only live plant anyone sold. There are reasons I didn't keep fish for several decades ... In any event, here are some lessons learned:
1. Learn about nitrifying bacteria, respect the cycle and do the necessary tank maintenance.
2. Bring fresh water up to tank temperature for water changes, or suffer the ich outbreak to come.
3. During water changes, keep a sharp eye on the end of the siphon and/or cover it with a piece of netting.
4. When doing a massive tank rescape, be kind. Move most of the water and all the fish, inverts out for a nice vacation in a well-aerated (and heated if necessary) "Hotel Rubbermaid" until the tank is settled and warm again.
5. Keep a hand over the net when transfering fish and inverts from one tank to another. The darned things wriggle, flip and jump, and it's sad to stare into a tank counting too few of something over and over again for 10 minutes only to look down and discover a drying body on the floor.
6. Study up on common ailments, causes and treatments. Try to buy likely meds or tank treatments in advance, and use them correctly and appropriately.
7. Decide on a humane method of fish euthanasia in advance. Do it the right thing for the fish.
The important thing is, when you lose a fish (or many), learn from it without giving up the hobby. We are all trying to create and maintain environments that we can never fully experience, and doing the best we can. And fish, like most other types of pets, live shorter lives than we do. Even if you did everything alsolutely perfectly, never made a mistake, never had someone or something out of your control go wrong ... still, keeping fish eventually means losing fish. It's what goes on between the getting and the losing that counts.
Hope this is helpful.