The reason is because of how the 2nd derivative is calculated for options and bonds.
Both formulas you provide are based from the Taylor series expansion of which you approximate small price movement to reflect the overall change in the value of a function, although the modified duration is negative for bonds.
Assuming you are long on a call and a plain vanilla bond.
call options – 2nd derivative is always positive if its a call. You can derive this formula but intuitively you can run some of your own calculation which will show gamma always being positive.
Bonds – If you derive the second derivative you will see that the 2nd derivative of a bond is always positive (the first derivative is negative – mod. duration).
Hence, applying the derivatives to the taylor series expansion causes the change in signs.
Ciao.