That's a poor comparison. Not all of the $30B in sales were fraudulent.
Actually, in order to come up with the $2B penalty, the gov't determines the number of fraudulent Rxs, then hits the manufacturer with triple damages (this is typical).
J&J would have been better off financially had they never committed the fraud they did.
You need to account for the probability of being caught. It's quite likely to be significantly lower than 1/3, so they might still have come out ahead.
Even if they're just breaking even, it's a kind of loan - they had the gain a long time ago, and pay the costs much later. If you're a risky business, that's potentially worth a lot, since investors might be hard to find.
And if you account for that you need to account for the asymmetry of risk due to bankruptcy protections - even if the average payout is negative, fines are effectively capped at what the firm can pay, so the effective expected payout may still be positive. (Assuming those making this decision escape personal liability).