Why do baby’s get Thrush?

Why and how do baby’s get thrush? How can you avoid it? My baby is formula fed