Here's what we can do without finance functions. We know that in $2$ years, a trip will cost us $ \$ 9500$. We want to make a deposit every month so that, after $2$ years, our account will have $ \$ 9500$ in it. Let's call our undetermined deposit $X$. Note that $t$ is time in months. $i^{(12)}$ is the nominal interest, $i$ is the effective annual interest.
At $t=0$ we make no deposit.
At $t = 1$ we deposit $X$. Its accumulated value will be $X(1+ \frac{i^{(12)}}{12})^{23}$
At $t = 2$ we deposit $X$. Its accumulated value will be $X(1+ \frac{i^{(12)}}{12})^{22}$
...
At $t = 23$ we deposit $X$. Its accumulated value will be $X(1+ \frac{i^{(12)}}{12})^{1}$
At $t = 24$ we deposit $X$. Its accumulated value will be $X(1+ \frac{i^{(12)}}{12})^{0}$
We notice that this is a geometric series since we are summing the values of our deposits, so
$$\sum_{n=1}^{24} X \left(1+ \frac{i^{(12)}}{12} \right)^{24-n} = X \left( \frac{(1+ \frac{i^{(12)}}{12})^{24} - 1}{i} \right)$$
by some algebraic manipulations.
Then, we know that our calculated future value of the deposits has to equal the cost of the trip, so
$9500 = X \left( \frac{(1+ \frac{i^{(12)}}{12})^{24} - 1}{i} \right)$ from which it is easy to calculate $X$.
(whew).
Annuities lump this huge amount of work into a very concise notation with a simple formula that is extraordinarily flexible, so I recommend you read up on it. Any good interest theory book will go over it. I learned from Kellison's book and found it to be quite good.
Your model is not correct, because it only accounts for the accrued interest, not the regular payments of $50$ each month. Instead, if $x_n$ is the amount in the retirement fund at the beginning of month $n+1$, you should have
$$\begin{align*}
x_0 &= 50, \\
x_{n+1} &= 50 + \left( 1 + \frac{0.06}{12} \right) x_n, \end{align*}$$
Note I have assumed that contributions are made at the beginning of each calendar month, and that the amount accrued is calculated right after the contribution. If you want the value of the fund just prior to the next month's contribution, you simply subtract $50$.
If we rewrite this recurrence as $$x_{n+1} = 50 + 1.005x_n,$$ then we can see one way to solve it is to find a constant $c$ such that $$x_{n+1} + c = 1.005(x_n + c).$$ This then requires $$1.005c = 50 + c,$$ or $$c = 10000.$$ Therefore, if we let $$y_n = x_n + 10000,$$ we get the simpler recurrence $$y_{n+1} = 1.005 y_n,$$ which forms a geometric sequence with common ratio $r = 1.005$. The solution to this recurrence is $$y_n = (1.005)^{n-1} y_0,$$ and with the initial condition $$y_0 = x_0 + 10000 = 10050,$$ we get $$x_n = (10050)(1.005)^{n-1} - 10000.$$ As there are $n = (65 - 20)(12) = 540$ payments from age $20$ to age $65$, not counting the payment that would occur upon turning $65$, the accumulated value is $x_{540} - 50 = 137750$.
The answer to the second part is simple; you would go through the steps I outlined above, except changing $50$ to some variable, say $K$. Then in the case where you start contributing to the fund at age $20$, we still have the same $n = 540$, and you solve the equation for $K$ such that $x_{540} - K = 10^6$, and for the case where contributions begin at age $30$, you adjust $n$ accordingly. I have left this as an exercise for the reader.
Best Answer
Your first deposit compounds for 120 months. The second for 119 months. Your last deposit for 1 month.
The future value of 120 deposits.
$10(1.005)^{120} + 10(1.005)^{119} + \cdots + 10(1.005)$
or
$\sum_{n=1}^{120} 10(1.005)^n$
This is the sum of a geometric progression.
$\sum_{n=1}^{m} y^n = \frac {y(y^m-1)}{y-1}$
to find this formula multiply by $\frac {1-y}{1-y}$
$\frac {1}{1-y}(1-y)(y+y^2 + y^3 + \cdots + y^m) = \frac {1}{1-y} (y - y^2 + y^2 -y^3 + y^3-y^4 + \cdots - y^{m+1})$
The expression "telescopes" leaving:
$\frac {1}{1-y} (y - y^{m+1})$ which equals the formula above.
plugging the numbers for this problem.
$10\frac {1.005(1.005^{120} - 1)}{0.005}$