Massive and modified gravity as self-gravitating media