That is closer to “empathy” than compassion. Compassion has no reason other recognizing the other person as “human”. “Mitgefühl” seems closer to understanding how the other person feels and therefore acting on it.. empathy.
Perhaps you could think of similar to the concept of “charity”. Doing beneficial things to others.. just because.