Like so much that is "heard" about shotguns in various venues, there is only one correct answer to things like that. And that answer is:
IT DEPENDS.
Firstly, there was a different sort of 870 made once upon a time called a Special Field. It had a shorter barrel and the distance between the breech and the barrel ring was different from "normal" 870s. Only Special Field barrels fit Special Field 870s, without having a gunsmith move the barrel ring of course.
Then there was the 870 Competition, which I just learned about a couple weeks ago for the first time in 35 years of messing with 870s. It was a gas assisted recoil control system equipped single shot 870 made for trapshooting. A number of its parts were unique, including the barrel. Not many of them were made and it is not at all common.
Any other barrel of the appropriate gauge should fit any other 870. Now keeping the magazine cap tight might be a different deal, but the barrel should fit no matter what.
All 870 Wingmasters, 870 Police guns, 870 Special Purpose guns and early 870 Express guns used the magazine cap detent in the barrel ring to keep the magazine cap tight. Newer 870 Express guns, the ones with dimples in the magazine tube, use the plastic teeth on the magazine spring retaining plug engaging matching teeth in the inside of the magazine cap to keep the magazine cap in place. While the barrels will certainly interchange, keeping the magazine cap tight without a proper detent for the barrel being used can be an issue. Guns that use detents in the barrel ring have dimples around the rim of the magazine cap to engage the detent, and a cup-shaped spring steel retainer for the magazine spring. New Express barrels lack both the detent in the barrel ring and the hole it was mounted in.
Unfortunately it isn't a hard and fast rule that X barrel will fit Y gun but Y barrel won't fit X gun. You have to learn to recognize the components of the two systems and select accordingly to get barrels that will properly work with your gun.
Good luck and good hunting,
lpl/nc