Core Graphics has (similar to PostScript and PDF), the concept of a "pattern color". See for example Patterns in the "Quartz 2D Programming Guide":
A pattern is a sequence of drawing operations that is repeatedly
painted to a graphics context. You can use patterns in the same way as
you use colors.
[NSColor colorWithPatternImage:image]
creates a pattern that draws the image repeatedly. So in your case, if the image has the same size as the window, it is drawn just once. But if the image is smaller than the window, it will be repeatedly drawn in x- and y-direction to fill the window background.