Elon Musk’s electric-car maker reported record quarterly profit for the final three months of 2022 and warned of an uncertain period ahead.