There certainly are different levels of criminal severity, and you've outlined that perfectly. But it has absolutely nothing to do with this because they're still stealing from someone. The people who prosecute and sentence the thieves can take those circumstances into account when determining an appropriate punishment.
Furthermore, you've failed to take your own example to its logical conclusion. The reason people are stealing baby formula in the first place is because it's too expensive. In fact, everything is becoming too expensive. That's a much broader and more serious societal issue than the act of stealing formula itself.