I think you may have misremembered what Marx said because this is in the preface of the Communist Manifesto: https://www.marxists.org/archive/marx/works/1848/communist-manifesto/preface.htm
that this struggle, however, has now reached a stage where the exploited and oppressed class (the proletariat) can no longer emancipate itself from the class which exploits and oppresses it (the bourgeoisie), without at the same time forever freeing the whole of society from exploitation, oppression, class struggles
This means you have to liberate others before liberating yourself.