Consider the following diagram.
We are asked to move each point ball one at a time until all the balls are collected at the pole (indicated by a blue circle). Find the minimum traveled distance. The total distance we travel back and forth to carry the balls must be minimized and it is the question. We start moving the ball from the most left.
My Attempt
I am not sure my attempt below is guaranteed to be the minimum.
Consider there are $i$ balls left at a certain point along the path to the pole. Let $f(i,d)$ be the traveled distance to move $i$ balls to the adjacent point to the right or \begin{align} f(i,d) &= (i+i-1)\times d\\ &= d(2i-1) \end{align}
Edit: We need to move forward $i$ times and backward $i-1$ times in order to move $i$ balls from the point under consideration to its adjacent point (on the right side).
Let $S(N,d)$ be the total distance traveled to move 1 ball from the most left to a certain point with $N+1$ balls. So
\begin{align} S(N,d) &= \sum_{i=1}^N f(i,d)\\ &= \sum_{i=1}^N d(2i-1)\\ &= dN^2 \end{align}
For the given problem, the final answer is \begin{align} \text{the minimum distance} &= S(11,3) + f(12,5) \\ &= 3 \times 11^2 + 5(2 \times 12 -1)\\ &= 478 \end{align}
How to prove that my answer above is the minimum?

I'm going to write an answer in my own words, but I think the details you have put in your own solution within the question are equivalent to what I write below and you have already proved that you have found the minimum total distance traveled. I can't even take credit for this, since every bit of it was anticipated in your solution. But I hope this explanation gives more confidence to your solution.
Given that you must travel right and left in a continuous motion (no "jumps"), that you can only move the balls by carrying them, and that you can only carry one ball at a time, for any point that sits between the flagpole on the right and $n$ balls on the left you must pass that point $n$ times going to the right. In order to pass a point $n$ times going to the right you must pass it at least $n-1$ times going to the left in order to be able to walk past it again in the rightward direction.
That makes $1$ trip over the $3$-meter space between the leftmost ball and the ball to its right, $3$ trips over the next $3$-meter gap between balls, $5$ trips over the next gap after that, then $7$ trips, then $9$, and so forth.
That's $1 + 2 + 3 + \cdots + (2n - 1) = n^2$ trips across a gap for the $n$ gaps between the leftmost $n + 1$ balls. Since each trip across a gap is $3$ m, that's $3n^2$ m total travel.
Let $n = 11$ to account for the gaps between all $12$ balls.
There must also be $23$ trips across the remaining $5$-meter gap to move all $12$ balls the final $5$ meters to the flagpole.
So the final total is
$$ 3(11^2) + 5(23) = 3\cdot 121 + 115 = 478. $$