Why don't combat aircraft have rear-facing weapons?
If your opponent is directly behind you, you have lost the fight. The point of basic fighter maneuvering, or BFM, is to keep your opponent off your tail and hopefully get on his. Everything you would learn as a fighter pilot centers around ensuring you would never have to use a rear-firing weapon.

In addition, visibility directly behind the pilot is typically poor; humans can't turn our heads 180 degrees, and if we could we'd be staring at the headrest behind us. A few fighters have had rear-view mirrors, typically ones with a two-piece canopy including the Eurofighter, F-15C and F-14 among others, but the one-piece bubble canopy on fighters like the F-16 and F-22 give no good place to put a mirror that wouldn't further interfere with the pilot's forward vision. Rear-view cameras would be laughed at by pilots as a waste of an MFD.

A cannon firing backward would also be a pretty single-purpose weapon; in a multirole fighter you might get a chance to use it to add insult to injury when pulling out of a ground run, but in all likelihood you'll either have peeled off to one side as soon as you pickled your bombs, or you'll be toss-bombing and not even overfly the target. The only real reason you'd ever fire it would be to keep someone directly behind you on their toes.