Both Congress and the President insisted at time of passage, and many of them still insist, that what the bill does is make it illegal to not buy healthcare with a fine if you disobey the law. They did this for several reasons including the fact that they had promised not to raise taxes, that the bill couldn't make it back through the House (where tax bills must start) so it was less Constitutionally suspect starting in the Senate if it didn't contain taxes, and that behavioral economics make it more likely that people will avoid a fine than a tax.
The Supreme Court decided that Congress doesn't have the power to do this. But that's okay, that's not (according to the Supreme Court) what Congress and the President really did. The majority on the Court decided that what the bill really did (in spite of the text of the bill to the contrary) was add a tax on people who didn't buy insurance. This is Constitution because of the taxing power. But wait, where is the taxing power in the Constitution?
Article 1, Section 8 The Congress shall have Power To lay and collect Taxes, Duties, Imposts and Excises, to pay the Debts and provide for the common Defence and general Welfare of the United States; but all Duties, Imposts and Excises shall be uniform throughout the United States
Congress doesn't have the power to lay and collect taxes as a penalty for something it dislikes. It can only do it to pay for things. There's a long established ability to exempt people from taxes for arbitrary reasons (thus the mortgage deduction, credit card interest deduction, charitable deduction...) but to my knowledge there's never been a federal tax raised specifically to discourage behavior the feds don't like.
So clearly Congress could have written a bill that raised everyone's taxes by $1000 and then gave an exemption to those who purchased insurance. The question is if that's actually what they did. Congress argues they didn't. The President argues they didn't. The minority on the Supreme Court argues they didn't. The US Attorney who argued for Obamacare argued it was a tax, but not that it was really a deduction. Even the majority on the Court doesn't actually argue they did, but it's the only Constitutionally consistent way to interpret their decision.
I should note that lots of commentators (like the one above) think the fact that the people who favor the bill still argue that it's not a tax even though the only reason it's Constitutional is that the Court decided it is. There's good precedent for that. The Roosevelt administration argued in Helvering v. Davis that Social Security is just a tax, not actual contributions, which is the only reason it was declared constitutional, but there are still very few arguments that the government doesn't have an obligation to pay you back.