Literally, it translates to “the fish dies by its mouth,” where the fish represents the person being talked about or even addressed directly, and “dying by the mouth” stands for being caught, hooked, or snagged. It refers to someone saying too much, or saying more than is good for them. That is, "el pez por su boca muere" means someone has given himself (or herself) away by saying something they did not mean for others to know.
The saying, “El pez por su boca muere,” is best understood if you put it into context.