What you are looking at are the spines of pufferfish, composed of nanocrystalline hydroxyapatite, protein(collagen), and water—the same materials as scales. Indeed, these spines are just modified scales. And like other scales, these spines originate during development, from the mesoderm layer of the dermis or the skin.
Dr. Brian Sidlauskas, Associate Professor and Curator of Fishes at Oregon State University, notes puffers evolved from a group of fish (porcupines, molids, triggerfishes, and filefishes) that all possessed ctenoid scales, denoted by small teeth along their outer edges. "Filefishes actually feel fuzzy. So it isn't perhaps too surprising to imagine those scales expanding and getting more and more spiny."
As you might expect, these spines evolved as anti-predator defense, similar to the ability of puffers to inflate. However, it looks like the inflation likely evolved before the spikiness.
If you want to know more about the bizarre and extremely-cute-yet-simultaenously-terrifying pufferfish, here's an informative short video from Science Insider, called "What's inside a puffer fish?" The video explains that when pufferfish puff themselves up (when they feel threatened or are trying to fend of predators), they are filling themselves not with air, but with water. A puffer has special muscles in its mouth that allows it to inhale water and pump it into its stomach, which makes its body inflate up to three times its normal size. The stomach is capable of expanding without being hurt because it is made of tiny folds, like an accordion. Puffers also have specialized muscles in their esophagus, which act kind of like plugs, to keep the water inside the stomach when they want to remain puffed up. And the base of the stomach also contains special muscles to help pump out water when the fish no longer wants to be inflated. Puffers also don't contain ribs or a pelvis, because those would get in the way of their ability to inflate. Finally, these tiny beasts contain a neurotoxin called tetrodotoxin, which is 1,200 times more poisonous than cyanide—one pufferfish can kill approximately 30 adult humans!
And yet, lots of folks around the world eat pufferfish as a delicacy. I've never had it, and I'm not sure I'd ever try it, given that, according to Delishably, around 100 people die from pufferfish poisoning every year:
More than 100 people die annually from puffer fish poisoning. Almost all result from consuming the world's most deadly delicacy. Throughout history, thousands have met their demise from fugu poisoning, primarily in Japan and China where it is more readily found in sushi restaurants.