This seems simple, but sewing a button onto something made of yarn can be much trickier than just a regular piece of fabric. Here is a step-by-step guide...
Start with threading decent size needle and doubling up the thread. Tie an overhand knot at the end of both threads together. Now you have a double-thick piece of thread through the needle you will be sewing with.
Decide where you need to have the button align and then on which stitch you want to attach the thread.
Bring the needle under the knit stitch, but only pull it through halfway. Then take the needle through the loop sticking out at the end, where your knot is from tying the thread together. This attaches the thread to the yarn before you add the button.
Thread the button hole and align the button where it needs to be. Sew the button on as normal, around and around through the holes.
When you've done this 10 times or so and it feels secure, bring the needle down through one button hole, but NOT through the knit. Your needle will pop out in the space between the button and the knit item.
Wrap thread around and around the base of the button 4-6 times (depending on how much thread you have left) and thread needle through all of the rounds you made into the knit item.
Knot the thread as usual on the back side of the knit (similar to how you attached the yarn in step 1) 2-3 times.