If we let $P_{i,j}$ be the likelihood of player starting with $i$ dollars, and ending with $j$ dollars after one move. Ignoring the edge cases for the moment, it should be clear that:
$$P_{i,i+k} = P_{i,i-k}\ \forall k<i,\text{ further } P_{0,j} = P_{10,j} = 1\ \forall j$$
The second condition due to the fact that the game ends once player $A$ hits $\$10$ or $\$0$.
Let's for a moment assume that player has $2\leq i\leq8$ dollars. We know there to be 5 possible outcomes: Breakeven, win a dollar, lose a dollar, win two dollars, lose two dollars.
$$P_{i,i} = \text{Prob}((HH,HH),(TT,TT),(TH,TH),(TH,HT),(HT,TH),(HT,HT))$$
$$P_{i,i-1} = P_{i,i+1} = \text{Prob}((HH,HT),(HH,TH),(HT,TT),(TH,TT))$$
$$P_{i,i-2} = P_{i,i+2} = \text{Prob}((HH,TT))$$
Notice that each pair of double coinflips individually has likelihood of $2^{-4} = 16^{-1}$. Conveniently, if we add all events above they sum to $1$. Note that I'm double counting cases when they don't break even because there are two symmetric outcomes.
The issue arrises around the edges. If player A has $\$9$ for example, and rolls two more heads than player $B$ then he moves to node 10 and not the nonexistent 11th node.Because of this you need to include the likelihood of 2 Heads into the movement of node 9 to node 10.
Hope that's enough to get you started. If you find this somewhat confusing, imagine this game for the simpler case with 6 dollars and everyone starts with 3. Same structure, different scale and easier to play around with.
Also recall that the transition matrix does not change over time. Further, the transition matrix does not care at all what the initial conditions are. The fact that they ask for a transition matrix given the initial condition of $\$5$ is a red-herring designed to trick/distract