Calculating RA/dec from JPL ephemeris data
Read the fine print under the Horizons output when you select an OBSERVER table. It says (emphasis mine)


  R.A._(ICRF/J2000.0)_DEC =
     J2000.0 astrometric right ascension and declination of target center.
  Adjusted for light-time. Units: HMS (HH MM SS.ff) and DMS (DD MM SS.f)


You could do the same, but it will take some extra work. The Mars you see at some time $t$ was emitted from Mars several minutes earlier than that. You need to find the $\Delta t$ such that the distance between Mars at time $t-\Delta t$ and Earth at time $t$ is equal to the speed of light times $\Delta t$. One correction will get you very close, a second will get you even closer.

Another issue is time. JPL uses its own time scale, JPL ephemeris time (Teph). This is a relativistic time scale. It differs from Terrestrial Time (TT) by at most a few milliseconds, so for most purposes you can use TT in lieu of Teph in your homebrew ephemeris calculator. TT currently differs from UTC by 67.184 seconds, and beginning in July (there's a leap second at the end of June), it will differ from UTC by 68.184 seconds.



Or you could just live with it. If you are using your calculations for your backyard telescope, the handful of arc seconds of error that results from not accounting for the finite speed of light is small.