You need to treat for ich for the whole of the ich parasites life cycle. In short after infecting your fish the parasite drops off the fish and goes to the substrate to reproduce. The next generation of ich then goes into the water column looking for a fish to infect. Its only during this free swimming stage that the medication will kill off ich. While your fish is visibily infected your medication is doing nothing, your fish either lives or dies regardless medication. You need to have the medication still in the tank for the time it takes for the parasite to reproduce and become freeswimming.
The timescale of the ich lifecycle is temperature dependant. In coldwater the whole life cycle takes a couple of months. At typical tropical fish temperature 2 to 3 weeks. At 30c about 1 week. This is where the one week treatment period after the last signs of ich comes from to make sure medication is still in the water. And why its important to raise the temperature of the water to speed up the lifecycle so you dont have to medicate for weeks and weeks. Raising temperature also means the infected stage is shortened and thus less harmful.
This is why people see ich come back time and again and why it can appear spontaneously. It wasnt killed off during its freeswimming stage. Ich can infect healthy fish and you see no signs. It can live in the tank, repeatedly going through its lifecycle for maybe years. Something affects a fishes overall health, ich takes advantage of a weakened fish and you see the visible infection again.