This second line of code solves the equation eqn1 for d and stores the solution in the variable ans. It does not automatically change the definition of d to contain the solution, as I suspect you may expect. So when you execute this next line:
d does not have the value you obtained by solving eqn1, it remains the symbolic variable d. So this solve call solves for D in terms of that symbolic variable d.
If I store the solution in a variable and either use that variable directly or substitute its value into the equation, that equation will use the value the first solve call computed.
eqn3 = subs(D/d == C, d, d_sol)