This is a tremendously complicated topic that varies wildly from company to company based on their ownership structure, sales strategy, and then wildly again from segment to segment or product to product.
Publicly traded companies have quarterly obligations to the shareholders, companies that are owned by a financial investment groups have variable goals based on if they're just building capital or prepping to sell that asset, and private companies have very different targets based on the objectives of their respective owners.
Quality and marketing are critical to maintain or improve in general to keep a company's brand perception positive. Taurus or example has been taking great strides to improve their perception. Ruger is remarkably consistent in that field, and you can set your watch on how predictable Glock is (and I mean that as a compliment). Springfield is highly effective at marketing to the masses.
Plus there's the sales channel strategy and how to set that mix, which is a wildly complicated subject that I'm not qualified to lecture anyone on save for noting that between direct dealers, distributors, chains, and direct to consumer options, you can wildly swing the needle by playing with you mixes and pricing strategy there alone.
For my bread and butter, the product line side; practically speaking, all gun companies will always have payroll and operations overhead we need to absorb. Some product lines might exist with a structure that's objective is to keep the lights on; it's not sexy, but it's a critical requirement some years just to keep hands busy and machines running. Some iterations of a product exist to cover for material or overhead inflation; so practically the product components shouldn't really cost more one model to another, but steel/polymer/electricity/shipping went bumped out cost up and we need to reconfigure or repackage the item to the customer in a way that allows us to increase price to maintain our margin requirements. Bespoke items have a strong individual margin on paper, but when you factor in the infrastructure you need to maintain to produce them and the units sold count, it gets to be a special kind of complicated. Military contract items are special because often the actual guns fulfill more of that overhead absorption role (legitimate MILSPEC delivered items have very tight tolerances) while any margin opportunity is more in parts, and the attached marketing lift. Then you get major innovation NPD for true incremental growth (think P365 redefining a market segment), and things get really complicated. I wouldn't be surprised if those took a minute to pay back the investments to turn a profit, and optimize but owning a critical segment means go go go. Also, all those items often take years to get done right; so timing the resource availability, development lead time, and the market trend for when something finally lands is like hitting a bullet with a smaller bullet whilst riding a horse (though that challenge is what makes it so rewarding to land stuff).
In my opinion, to really play this game well, a company needs to be orchestrating all of those parts together. A robust operations and quality system to keep things on the level. A cohesive marketing strategy to message correctly to the end customers that dovetails with your cleverly mixed channel strategy (aka the people we actually have to sell to). A product plan that can mix several of the types of product opportunities to get growth and operations stability and be insulated from over relying on any single segment in case that product fails or the segment goes in an unpredictable direction (legislation, don't win a contract, a vendor leaves the network, etc).
There's so much more that has to happen behind the curtain to consistently make all of that work together to provide stable and long term success.
In my opinion as an industry insider, if I had to isolate one thing to drive success for profit and product? It simply comes down to having the right people in the company. You need the right balance of passion and prudence at every corner of the organization from top to bottom to drive innovation without betting the farm. You need people who know and care about the product enough to ask all the right questions years ahead of everyone else, but who aren't such hardcore fans they can't step back and pivot if its just not the right time to dedicate those resources at that time. You need people who communicate well internally so good ideas or red flags on issues don't get bottlenecked, discarded, or swept under a rug. Critically, it takes a special kind of crazy. You get enough people together who can do all that and give them enough resources? They'll take over the world, or a % of the world commensurate to the resources provided.
Beretta specifically? I can say our standing orders currently are to plan on how to celebrate our 500yr anniversary with a roadmap to keep us around for 500 more, and the passion is certainly there across a ton of the global org.