Anything that gains EXP points will gain EVs.
So both Pokemon will gain EVs, and the distribution is just like they had battled the Pokemon themself. So if my Mewtwo holding a Macho Brace defeats a Bellsprout, and my Mew is holding the EXP share, Mewtwo will gain 2 Attack EVs, and Mew will gain 1.