Now there are other considerations. SpaceX has a number of good PR reasons to want to be upfront about their costs (their competition is regularly accused of cheating the government every election cycle). If you sell retail your customers will ignore you if you don't have pricing information.
The competition aspect is pretty commonly worked around - basically every B2B company I know has no compunctions against calling up a competitor, posing as a potential customer, and getting a price quote for competitive research. Or if they have slightly more compunctions, they'll call up a market research firm, hand over some money, and the market research firm will call up all the competitors in the industry, pose as a potential customer, and sell that information back to all the competitors in the market.
I suspect that SpaceX's published price tag is really there to motivate the employees. It's a reminder that Elon's goal is to make spaceflight a mass-market product that an ordinary middle-class citizen can afford, and so he wants that number to go down over time. In many B2B markets without price transparency, there's a tendency towards lazyness on the engineering side; when your revenue comes from how effective your salespeople are at jacking up the price, there's little incentive to focus on small efficiencies that keep the overall price down. Elon wants to keep the focus on small efficiencies so that the price gets low enough that it becomes an everyday thing.
I used to work for a company that had a single product and sure we've lost a few customers to our competitors because of our pricing, but judging by what they chose instead I don't envy them.