Quark is not intended to be an upstanding role model.
Quark is from a race that wasn't even discovered until TNG. When a Federation officer speaks of "in the 24th century", they are not saying "and Ferengi and Klingons and the Borg are unified in this." They are speaking of Federation civilization.