It can be tricky when switching back and forth from knit to purl in the same row. It's very easy to drop stitches or to create yarn overs.
In order to make sure you don't end up with extra loops, you need to move your yarn from front to back, or back to front, just before you try to make the stitch that needs it. In a k2, p2 ribbing, you start off with your yarn in the back of your work. Knit two stitches, and then bring the yarn forward between the needles. Your yarn is now in the correct position to do the two purl stitches. After you have purled two, you bring the yarn to the back in between your needles, and then it is in the correct place again for your knit stitches. Clear as mud?