Though both a Tandemaus/Maushold that already know an egg move, as well as a Ditto, can breed to produce eggs with an egg move, Tandemaus/Maushold can't learn these moves through breeding otherwise. As a result, to get Tandemaus/Maushold with After You, there's an additional method newly introduced in Scarlet/Violet for exactly that,
In Pokémon Scarlet and Violet, if the player has a picnic with one Pokémon that holds a Mirror Herb and has an empty move slot, and another Pokémon that knows a move the first Pokémon can learn as an Egg Move, after the picnic the first Pokémon will learn that Egg Move, even if there is no matching Egg Group or if both Pokémon are of the same gender. This does not consume the Mirror Herb.
As a result, plenty of Male-only and Genderless Pokémon were able to receive egg moves that never could before, including Tandemaus/Maushold. Just leave your Tandemaus/Maushold in a picnic holding a Mirror Herb with an empty move slot, and another Pokémon that knows After You, and your Tandemaus/Maushold will learn After You.
Source