YF-23 had faster supercruise, a much bigger range, and had a way larger internal ordinance bay (external ordinance kills stealth). They intentionally skipped the sexy vectored thrusters for B-2 style inset exhausts which make infrared signature much smaller (especially to ground-based attackers). This meant the YF-23 could have delivered more ordinance faster and farther while having higher rates of mission success due to better stealth.

F-22 won the competition on two and a half points.

First and foremost, the YF-23 was going to be built in 10-11 states while the YF-22 was going to be built in almost 30 states, so something like 40 senators had their state's financial interests at stake with the jobs this would bring in (though nobody involved would ever openly admit this was one of the big reasons). Of course, spreading stuff out increases all kinds of costs and with so many small places, once the main run of planes was done, all these sub-contractors moved on too. As a result, the US can't get all the F-22 parts they need and the F-22 is going to be scrapped way before what would otherwise be necessary.

Second, is that the F-22 had vectored thrusters, so was theoretically more maneuverable. This is somewhat debated because making a YF-23 variant with vectored thrusters was possible and even without it was more than capable of turning a pilot's brains to mush (by far the biggest limiting factor for any manned fighter). Ironically, the big selling point of the F-35 is to be so stealthy that you can kill targets before they can see you due to stealth without the need to dogfight which was the exact YF-23 strategy too (and of course, vectored thrust seems to be a needless and cost-adding addition to the F-22 as the strategy for them is also to engage at ranges where maneuvering isn't a critical task). In every other category of consideration, the YF-23 was far ahead of requirements while the YF-22 was barely satisfactory.

The half point is the stated delivery concerns. The Air Force claimed they were worried that the planes wouldn't be delivered because the B-2 was already behind schedule. As EVERY plane is ALWAYS delivered behind schedule, this is very dumb reasoning. While the YF-23 team had worked for years to make a ready-to-ship plane in the YF-23, the YF-22 was a cobbled-together mess to the point that the entire airframe was redesigned multiple times. As a result of this and that spread-out construction crew, the F-22 was way behind schedule and way overbudget.

Northrop Grumman allegedly asked about using YF-23 designs in a bid for the next-gen Japanese fighter project, so maybe there's hope for it yet (I'd note that the profile of the Russian SU-57 has a strikingly similar look).

EDIT: As to the B-52, the real issue is that making a new plane would give marginal benefits to the airframe while the retraining and costs would be large (not to mention the usual teething problems of a new design). This is similar to how they tried so many times to replace the m4. Better systems exist, but they weren't worth the upgrade (lots of people suspect that their new rifle will be too heavy for most soldiers too).

The most profitable upgrades to the B-52 are the internals and electronics and this has been done several times.

The second best upgrade is more modern and efficient engines, but this has been a very slow to happen. They've announced plans to do this, but I suspect it will be longer than they think. They are claiming reduced maintenance time and a 30% increase in efficiency. Not a bad upgrade, but also not that huge when you consider that's basically 0.5% for each year since it was first designed.