When they have used up their losses to off set income.
The reason Amazon gets this is because they lost literally billions of dollars getting started. That gets banked to off set future earnings. That is not scandalous or wrong. It's a part of allowing people to take risks in starting new businesses. Sometimes that happens with long term companies too.
Our company lost a lot of money between 2008 and 2011. While doing so, we racked up a lot fo debt also to stay alive. One benefit from the losses we were able to carry forward was that we were able to use that cash to pay down debt instead of some taxes. Now, we are back to paying taxes, less debt and in much better shape for the next recession when it comes.
When our company used past losses to off set income, it wasn't scandalous or wrong. It's part of doing business and having a tax environment that helps companies that take losses either when they are started or have a bad year.