When a pattern says to rib for an inch, then it's from the cast on edge up to your needle.
For 2 x 2 ribbing, it's k2, p2 all the way across. Your pattern says an even number of stitches, but for k2p2 ribbing on a hat, you should make sure that even number is also a multiple of 4, since there are 4 stitches in each 'group'.
So if you have a multiple of 4, and you start with a k2p2, then each row can be k2p2 and you should get normal ribbing. If for some reason, you don't want a multiple of 4, just remember that if you end with a purl, start with a knit; if you end with a knit, start with a purl.