Because they can be sold at auction, bonds appreciate or discount until they are mathematically identical to bonds being sold at other rates.
Let's say you have a $1000 bond with a 4% rate, which you bought last year. This year, due to economic changes, the equivalent bond sells with a 5% rate. At auction, last year's bonds (those with a 5% rate) only have to match a 4% return on capital, because an investor knows that they could also just as easily buy a new $1000 bond that would return 4%. A 5% bond would sell for $800 now, because that's all it's worth--otherwise, why wouldn't you just buy one of those new 4% bonds? Here, the increase in interest rates has caused bonds to appreciate.
On the other hand, if this year's bonds are at 3% and last year's bonds were at 4%, the old 4% $1000 bonds will sell for $1333 because the going rate is $30 per $1000 of capital, so you're willing to pay $1333 to get a $40 return. Thus, when interest decreases, bonds appreciate.