Gauge Help

I am a beginner. I understand the basic idea, but am having trouble putting it into practice.

I have a pattern that says find the right needle for the right gauge - there is a pattern for 4 stitches/in and 5 st/in. I am aiming for 5 st/inch.

I have yarn that calls for 18 st and 24 rows in a 4x4 square. I am getting the 18 stitches in 4 inches horizontally. However by 24 rows, I am only at 3" vertically. The average comes out to 4.5 st/inch.

Now, do I need a bigger needle? a smaller needle? this size is working - size 8 needle is what I am using.

The rows don’t matter as much as the stitches per inch. In fact, I never pay attention to the rows; usually, the pattern will tell you how many inches you need to knit, so I just go by that. The stitches per inch matter a LOT, especially if you’re knitting a garment. Since you’ve got the stitches per inch, knit away!!

Here is a great page on Guage

You could go up one needle size if you want; I’ve found that it doesn’t affect the stitches/inch as much as the rows per inch. But it’s true that rows/inch isn’t as crucial as the stitch gauge - you can always make something a few rows longer and most pattern say to knit for X inches, not rows.