I don't know what watch you are referring to, and I don't follow Breguet closely enough to know what models they offer. Assuming you are referring to a minute repeater or a sonnerie, these watches can chime the time either on demand (repeater) or just as they run (sonnerie). In some cases watches can do both, so that is a grande sonnerie watch, and quite rare.
Not all repeaters chime down to the minute - some are quarter repeaters that only chime the closest 15 minutes or 1/4 hour, some are 5 minute repeaters, etc.
In a repeater, when the slide is pulled or button pushed, it winds a spring that drives a mechanism inside that has small hammers and gongs that are struck that make the sounds. Video of a pocket watch repeater I had in the shop years ago:
You can likely Google to learn how these work in more detail, so I'm not going to go into great depths here...
How does it know the time? Well there are a few ways to answer this, but the simplest is that it's a watch.
😉
Any watch is a series of gears that travel at a known ratio to each other, so over a given time frame they will move a known amount. If a watch has hands, those hands are in a specific relationship to each other that tells the time. If you have a watch even with just a simple complication like a date, it has to "know" when midnight is by the hand positions. Here the hand positions simply match the rotation of some other parts so that the chime corresponds with the hands. If some watchmaker puts the hands on incorrectly, then the watch no longer "knows" the correct time. It's not magic, just some engineering.
Many consider the tourbillon one of the highest feats in watchmaking, but repeaters are a step above that IMO.
Cheers, Al