As I explained here yesterday, the Church teaches that possessing excess wealth is theft, regardless of how someone obtained that wealth. Therefore, giving away excess wealth is an act of justice, not an act of charity. Charity does not apply until someone is giving from their need rather than their surplus. As the Catechism says, “The demands of justice must be satisfied first of all; that which is already due in justice is not to be offered as a gift of charity” (CCC 2446).
Giving to the poor is both a work of justice and a work of charity. (See ccc 2447 for example.) They aren’t mutually exclusive concepts.