General vs field specific journals in mathematics
It's a bit difficult to disentangle this issue from prestige, since many of the most prestigious journals in mathematics are general.  

At the very top of the prestige scale (Annals and a handful of competitors), there are no specialized journals at all.  Specialized journals start to appear a little lower on the scale, and they become more common as one descends further, as well as more specialized.

To a first approximation, prestige is the more important factor.  For example, given a choice between GAFA and Transactions of the AMS, GAFA wins on prestige despite being quite a bit more specialized.  There may be other reasons you might prefer the Transactions (for example, the publisher's policies, or a desire to support the AMS), but if building an impressive CV is your primary motivation, you should go for prestige.

On the other hand, going with the broader journal is a good heuristic if you aren't sure which is more prestigious or don't think there's a big difference, since it's correlated with prestige and therefore tends to give a good impression.

Towards the bottom of the prestige pyramid, people may raise an eyebrow at overly specialized journals, since a paper acceptance doesn't mean much if it's in a venue specifically designed to ensure that specialized papers not easily publishable elsewhere find a home.  Of course that doesn't mean the papers are bad, but they won't look impressive on a CV.