Computing quotient by dividing formally in $p$-adic number system From Gouvea's p-adic Numbers:

To pass from positive integers to positive rationals, we simply do
  exactly as in the other case, that is we expand both numerator and
  denominator in powers of p, and then divide formally. The only thing
  one has to be careful with is that one may have to 'carry.' The sum of
  two of our $a_i,$ for example, may be larger than p, and one has to do
  the obvious thing. It's probably easier to go straight to an example.

Here is his example:

Let's take $p = 3$ and consider the rational number 24/17. Then we
  have 
$ a = 24 = 0 + 2 \times 3 + 1 \times 3^2 = 2p + 2p^2$
and
$ b = 17 = 2 + 2 \times 3 + 1 \times 3^2 = 2+ 2p + p^2$
(Though of course $p = 3$ it's probably less confusing to write $p$,
  because one is less tempted to "add it all up." The point is to
  operate formally with our expansions.) Then we get
$\frac{a}{b} = \frac{24}{17} = \frac{2p + 2p^2}{2 + 2p + p^2} = p + p^3 + 2p^ 5 + p^7 + p^8 + 2p^9 + ...$

I'm having trouble understanding what this formal division involves, and my attempt to perform conventional polynomial division hasn't yielded this series. 
I had more success when I rewrote the numerator and denominator ($\frac{2p + 2p^2}{2 + 2p + p^2} = \frac{p^3-p}{2p^2 -1}$) and then performed something like conventional polynomial division (dividing the lowest power into the lower power). This is fine, but I can't figure out why this would work, or how I should "divide formally" in general.
Any help, please?

My method is much more direct, and to my mind, much more intuitive than that of @BenjaminDickman. Conceptually, it’s exactly like long division of decimally expressed reals, as you (one hopes) learned in elementary school. Unfortunately, it proceeds right to left, assuming that you write your $24_{10}$ as $220_3$ and your $17_{10}$ as $122_3$. I think that all you need to know is that $-1$ is written $3$-adically as $\cdots22222_3$. I’ll drop the subscripts from here on, but in case you doubt the infinite expansion of $-1$, notice that it represents $\sum_{n=0}^\infty2\cdot3^n$, a geometric series with initial term $a=2$ and ratio $r=3$, which is three-adically smaller than $1$, so that the series is convergent. And the value is $a/(1-r)=2/(-2)=-1$.
Step 1. Write the dividend on the left, the divisor on the right, leaving space above for the quotient. See in this case that the first digit is $0$, the second is $1$, so you will want to subtract $10\times122$ from the dividend.
\begin{matrix}
\text{(quotient)}&&&&&&1&0\\
&0&0&0&0&2&2&0&\bigl(&1&2&2\\
&(-)&&&1&2&2&0
\end{matrix}
Step2. Do the subtraction
\begin{matrix}
\text{(quotient)}&&&&?&0&1&0\\
&0&0&0&0&2&2&0&\bigl(&1&2&2\\
&(-)&&&1&2&2&0\\
&2&2&2&2&0&0
\end{matrix}
Here, you got a free digit of zero in the difference, so put a zero upstairs and ask what the next digit should be. You’re asking what the first digit of $\cdots2222/122$ should be; clearly $1$. So in the next step you’ll subtract $1\times122$ from the lowest line, but properly aligned. I’ll perform the subtraction, too:
\begin{matrix}
\text{(quotient)}&&&&&&1&0&1&0\\
&&&0&0&0&0&2&2&0&\bigl(&1&2&2\\
(-)&&&&&&1&2&2&0\\
&2&2&2&2&2&2&0&0\\
(-)&&&&1&2&2\\
&2&2&2&1&0&0
\end{matrix}
I won’t go any further, but you see that the next nonzero digit is going to be $2$. You need to do the multiplication, $2\times122=1021\>$, and continue this way. Unfortunately, this method is a natural for demonstration on the blackboard, but the static nature of the written (printed) word is almost completely unsuitable. I keep telling myself to make a video, but laziness seems to be holding me back. Anyway, my machine tells me that the quotient is $\cdots12\,02\,12\,21\,10\,20\,10\,10;$ Our rational number must have a periodic three-adic expansion, but since $\langle3\rangle$ is of multiplicative order $16$ in $\Bbb Z/17\Bbb Z$, the period of that expansion must be $16$, not so easily observed.
