It’s possible that Hagrid let it slip when talking to them.
We know that Hagrid goes into the Forbidden Forest and sometimes talks to the centaurs. We also know that Hagrid had a hard time keeping information about the Philosopher’s Stone a secret.
“Oh, a fair few … Keep themselves to themselves mostly, but they’re good enough about turnin’ up if ever I want a word. They’re deep, mind, centaurs … they know things … jus’ don’ let on much.”
- Harry Potter and the Philosopher's Stone, Chapter 15 (The Forbidden Forest)
It seems possible that Hagrid could have told them that the Philosopher’s Stone was in Hogwarts. He accidentally gave Harry enough information to figure it out, and Harry was an inexperienced eleven year old who’d just learned about the wizarding world.
It seems unlikely that they divined it - centaur divination is broad.
While it’s possible that the centaurs divined the Philosopher’s Stone being in Hogwarts, from what we know of centaurs’ divination, it tends to be broader and not really focused on details.
“Sybill Trelawney may have Seen, I do not know,’ continued Firenze, and Harry heard the swishing of his tail again as he walked up and down before them, ‘but she wastes her time, in the main, on the self-flattering nonsense humans call fortune-telling. I, however, am here to explain the wisdom of centaurs, which is impersonal and impartial. We watch the skies for the great tides of evil or change that are sometimes marked there. It may take ten years to be sure of what we are seeing.”
- Harry Potter and the Order of the Phoenix, Chapter 27 (The Centaur and the Sneak)
From this, it seems like they wouldn’t get that level of details from the stars. It also seems like divining things can take time, so they probably wouldn’t find out what’s happening as it happens. When we hear one of Firenze’s predictions, it’s very broad, and doesn’t give specific details on anything.
“In the past decade, the indications have been that wizardkind is living through nothing more than a brief calm between two wars. Mars, bringer of battle, shines brightly above us, suggesting that the fight must soon break out again. How soon, centaurs may attempt to divine by the burning of certain herbs and leaves, by the observation of fume and flame …”
- Harry Potter and the Order of the Phoenix, Chapter 27 (The Centaur and the Sneak)
Ron described the lesson as nothing very definitive, and low on details.
“He’s not very definite on anything, is he?’ said Ron in a low voice, as they put out their mallowsweet fire. ‘I mean, I could do with a few more details about this war we’re about to have, couldn’t you?”
- Harry Potter and the Order of the Phoenix, Chapter 27 (The Centaur and the Sneak)
It doesn’t seem like they’d be able to divine the presence of the Philosopher’s Stone.