To answer a couple questions that I haven't seen anyone address, both the 870 and 500 have a lot of aftermarket stocks and accessories. Both have receivers that are drilled and tapped for scope mounts or rails. Lights can easily be attached to either.
Being a little more subjective, it is generally thought that pistol grip forends like
this aren't a great idea, because they aren't aligned directly with the pump slides and tend to create more friction and gun movement when pumping. You see them in movies and youtube videos, but I don't think you'll find them on many military or law enforcement shotguns.
Someone else already mentioned this, but pistol grip
only (PGO) stocks like
this generally aren't recommended. Without something against your shoulder, aiming will be tougher and keeping the gun steady for follow-up shots will be very difficult. Again, these are more popular in Hollywood and Youtube than they are with people who have serious need for shotguns.
As far as a traditional stock vs. a pistol grip stock, that seems to be more about personal preference than anything else. I like a traditional stock, but someone who's used to ARs may feel more comfortable with a pistol grip stock. As others have mentioned, the safety location on the Mossberg is probably better suited to traditional stocks.
With either stock design, some people prefer a shorter length of pull on defense shotguns. This can reduce the chance of snagging the gun while bringing it to the shoulder, but a shorter stock also allows a person to shoot from a more squared up stance (rather than an angled stance used for most shooting). The point is that a person can maintain better balance and have a greater range of upper body motion when they start out squared. Many pistol grip stocks are adjustable for length. Among traditional stocks, the
Hogue 12" length of pull stock is popular for those wanting a shorter stock.
You asked about rails, and a person can certainly use various optics on a shotgun, but for home defense ranges, optics may not be any better than open sights. Tritium front beads may be helpful in some darker situations. The Big Dot sites at the bottom right corner of
this page seem well liked.
Choice of sights and stocks can be interdependent, because the comb height of different stocks will raise or lower your eye level in ways that may be better suited to higher optical sights or lower open sights.
Getting back to 870 vs. 500, the 500 comes with 6-shot capacity while the 870 comes with 5-shot capacity. However, the 870's magazine can be extended with aftermarket parts and the 500's can't. If you ever want to buy extra barrels for either gun, the mossberg barrels are significantly less expensive.