So you have to pivot the array. Here are some quick examples:
function transposeArrays(){
let ss = SpreadsheetApp.getActiveSpreadsheet();
let sheet = ss.getSheetByName('Data');
// pivot single column array from vertical to horizontal
let vData = sheet.getRange("A1:A10").getValues().flat();
let newHData = [];
vData.forEach(e => { newHData.push(e) });
// pivot single row array from horizontal to vertical
let hData = sheet.getRange("A1:J1").getValues().flat();
let newVData = [];
hData.forEach(e => { newVData.push([e]) });
// switch rows & columns on full range
let fData = sheet.getRange("A1:D4").getValues();
let newFData = fData[0].map((col, i) => fData.map(row => row[i]));
}