Basically 99% of problems can be traced to fishkeeper error or lack of knowledge. My first fish were 6 cardinal tetras. Perfectly cycled tank, but I did not realize the ordeal the fish go through, and placing them in one more tank was enough to give them what looked like NTD but maybe was a fungus. Learned 2 lessons after I took the time to re-examine.
#1- Know your fishkeeping limits. I did a TON of research and was actually planning on a tank with GBRs as the center piece, with rummy noses and cardinals. All sensitive species. None suitable for a beginner, but I thought I could swing it since I wasn't going in blind. Heck, I didn't know what I didn't know tho. Went back and got some zebra danios. Very hardy, underappreciated fish btw. Super common, but a delight to watch and very beautiful. Watching them, noticing things like the tiny barbels, the gold tint males take on. Man I wish I started with them first.
#2 Fish health is all about lowering stress levels. A fish's diet, water parameters, tank mates, decor/lack of decor, and a thousand other factors all contribute to fish stress levels, either raising or lowering it. All environments carry pathogens. Bacteria, fungus, etc. There is no getting around that. If a fish is in optimal environment, and not stressed it can fight whatever is present. If not, fish immune system will be fighting on its back foot and may succumb to what a healthy fish can fight off. This doesn't include parasites however, however I've had ich in a fish show up six weeks after getting him, so maybe even parasites can be kept at bay in a healthy fish. Those cardinals were definitely stressed tho, my new tank was the nail in the coffin.
Just recently I lost 3 zebra loaches. Literally lost em. Gorgeous fish, hit me hard. Nitrates were creeping up despite maintenance, so I decided to pull apart the tank to get to some dead leaves and poop I had a hard time removing. I'm pretty sure they were wedged in my driftwood that I took out to gravel vac the tank. Stupidly I placed the wood in a shallow tub, they may have jumped out. Haven't seen em since. :-/