As written down, your code describes a motion with constant acceleration (see $a_k=a_{k-1}$), so the trajectory will simply be a quadratic function (parabola).
Every moment $dt$, the velocity changes by the obvious amount, $dt\cdot a$. The same is true for position which changes by $dt\cdot v$ but there is an extra piece $a/2\cdot dt^2$ in the change of the position. This term is infinitely smaller than the main term, $dt\cdot v$, and if $dt$ is short enough, you may neglect it.
However, if you include it, you get a higher accuracy of the simulation even if $dt$ isn't too small. Why? Because the change of the position $p$ during the time $dt$ is calculated as $dt$ times the average velocity in this short time interval. And because the velocity is changing approximately linearly, the average velocity is
$$ \overline v = \frac{v(t)+v(t+dt)}{2} = \frac{v(t)+v(t)+a(t)dt}{2} = v(t)+\frac{a(t)dt}{2} $$
If you multiply this $\overline v$ by $dt$, you get the change of the position $p$ as incorporated to your first equation.