[SPARK-3465] fix task metrics aggregation in local mode

Before overwrite t.taskMetrics, take a deepcopy of it.
Could you elaborate on why we need to do this in the comment?