As Vector57Vector57 noted, the problem is you are using the wrong coordinate system. The algorithm described is meant to be used with cube coordinates, which have x, y and z components:
This may not be obvious from the algorithm's pseudocode, but that's because it's a simplification of this:
var results = []
for each -N ≤ dx ≤ N:
for each -N ≤ dy ≤ N:
for each -N ≤ dz ≤ N:
if dx + dy + dz = 0:
results.append(cube_add(center, Cube(dx, dy, dz)))
... a plain nested loop over x, y and z, what you'd expect from a range algorithm.
I don't know what coordinate system you are using, but I'm guessing it's one of the "offset coordinate" systems, which are popular because they are easy to implement by placing the grid cells inside a 2D array:
This doesn't mean you can't use these cube algorithms; it just means you need to convert from the cube coordinates to your own. For example, to convert to/from the "odd-q" vertical layout, use these:
# convert cube to odd-q offset
col = x
row = z + (x - (x&1)) / 2
# convert odd-q offset to cube
x = col
z = row - (col - (col&1)) / 2
y = -x-z

