To guarantee your knitting matches the gauge of the pattern as given, make a SWATCH. This is the best way to make sure your garment will turn out to the dimensions that the pattern is written for.
Read the gauge info given and cast on however many stitches they say fits in 4" plus a couple extra.
Knit as many rows as they say should be in 4" as well.
Measure YOUR gauge by lining up a ruler along stitches and count horizontally.
Do the same for rows vertically.