Вы должны добавить круглые скобки вокруг возвращаемого объекта, чтобы отличить его от простого блока:
const my_arr = [1, 2, 4, 3, 4];
const data = my_arr.map((element, index) => ({ a: element, b: index }));
console.log(data);
Или вернуть его явно :
const my_arr = [1, 2, 4, 3, 4];
const data = my_arr.map((element, index) => { return { a: element, b: index }; });
console.log(data);