Think about it this way. Example 1: A bond has no more coupon (interest) payments left and is going to pay out 100 at maturity[1]. The price where the bond is trading now is how much people are willing to pay now for that 100 in the future when the bond matures. So say the bond has a year to run from today and the price is 90. If the price goes down, the person purchasing that bond is paying less for that future 100. The "yield to maturity" has gone
up. The same is true if the price goes up from here - the "yield to maturity" goes down.
OK now add in some interest payments. Say the bond has a year to go and pays 4 interest payments (one per quarter) with 100 at the end. The coupon payments are a fixed dollar amount that is specified at issue[2]. So say for ease of calculation it's going to pay 4 payments of 1 dollar, with the last one coming with the 100 dollars of principal paid back at the end.
It's easy to see that the previous relationship still applies - the price today is the value of all those cashflows discounted by some rate. If the price goes down, that means investors want a higher rate (because they are prepared to pay less for the future cashflows).
Hope that's clear.
Now when you add in other factors (eg risk and severity of default) it's easy to see that these are effectively a spread on the discount rate applied to these future cashflows. You're not really changing anything else just the cashflows are a bit more (or less) risky. So the central relationship - (price up = yield down and vice versa) still holds. These spreads are just another thing that might cause the price to go up or down.
Finally consider that you don't have to invest in this one bond, you could put your cash somewhere else instead. So if the yield available on similar instruments elsewhere in the market changes, the price of this instrument will adjust such that the yield works out about the same as other instruments that are believed to be about as risky. This makes sense just like if bank A starts offering a better rate on savings, people will start moving their savings there so bank B has to offer a better deal. In the same way, if interest rates in general go up, bond prices have to go down so that the yield to maturity they are offering to investors is competitive.[3]
[1] Or it could be a zero-coupon bond that pays no interest. I'm simplifying a bit by removing default, recovery, prepayment etc to make the central relationship clear.
[2] They aren't always fixed but I want to make sure you get the simplest case really solid in your mind because the complex cases don't change things too much actually.
[3] All other things being equal yadda yadda. Bonds are actually very complicated but this central relationship should at least be clear. One thing to note is different bond prices are more or less sensitive to changes in rates, which is why some of the key metrics (Duration, Convexity, DV01) track this sensitivity. One way in to thinking about this is the maturity of a bond. Say the bond is fixed rate with 100years to mature, that is going to respond to rate changes very differently to one with only 1 cashflow left expiring in 1 year because of the discounting I mentioned earlier.