It’s all about how you push into the pegs while you are turning them. Think of this process like having a nail, and you are trying to put that nail into a piece of 2×4 wood. You couldn’t (manually) put that nail in unless you twisted while pushing. That concept is the same with pushing pegs into the peg box–twisting is just as important as turning. If you do it properly, you can actually make the peg so tight that it is hard to turn.
I know you can also apply peg compound when your pegs are loose. But that is only good when your pegs become loose because of the humidity, if your pegs become loose because of the peg holes have become enlarge, then you will have to bring the violin to the luthier to get it fixed.