From the way your request is written it sounds like maybe you mean pilling, but to be sure I'll cover both.
Felting is when you wash a knitted item and it shrinks and creates a solid fabric.
To keep feltable fabrics from becoming felted don't wash them as you normally do. It's best to gently hand wash in cool water and lay flat to dry. You can also use superwash wool or a blend that doesn't felt.
Pilling is when you get the little balls of fluff on your knitted fabric. Any yarn can be subject to pilling. It has more to do with the way the yarn is spun. Pilling usually occurs when there is friction like between arm and side or in the laundry. There is no absolute way to prevent it, but if you wash gently and use a sweater shaver it helps. The fabric you show in your photo could use a sweater shaver to look nice again.