You won't be able to avoid muscle loss if you take signficant breaks from training. This is called deconditioning.
Illness will cause more loss than a simple break from training though, because your body may start to break down your muscle for energy. To avoid this, you need to try really hard to feed yourself well while you are sick.
Breaks are sometimes unavoidable, but in the long-run you should be still getting stronger, so don't worry too much.
Here are some ideas for how to avoid deconditioning during breaks:
- do some exercise
- if the break is due to injury, try crosstraining with a different activity
- focus on nutrition