What getValues actually gives you
getValues returns a 2D array: an array of rows, where each row is itself an array of cell values. A three-row, two-column range comes back as [[A1,B1],[A2,B2],[A3,B3]]. That 2D shape is not optional -- setValues requires it, and flattening it (even accidentally) triggers the parameter mismatch error: 'The number of rows in the data does not match the number of rows in the range.'
The classic for loop sidesteps this by never changing the shape at all; it just reads and writes by index. When you switch to map and filter you start transforming the array, which is where the shape problem surfaces.