Yeast infection

CC
How do you get a yeast infection. I went to the doctor because I had a lot of white smelly discharge and she told me I had a yeast infection I took the pills followed the instructions. And two weeks later I have another yeast infection(or so I assume because I have the same symptoms as before). How does this happen