The referee counts in approximated seconds in their head. In practice this leads to variations in the number of actual seconds in the count, but in nearly all cases it’s perfectly acceptable as an approximation.
A particularly fast or slow count can lead to controversy and the perception of unfairness to either boxer. The Queensbury rules state it should be ten seconds, but this is hard to do in practice. Stopwatches are not used and the referee’s judgement is final.

In modern boxing there is a ringside official who times the start of the count on behalf of the referee from the knockdown and relays this to the referee to continue the count.
The referee says the number out loud, and gestures with his hands so the downed boxer is aware of how long they have to stand up, unaided. Being knocked down can affect hearing as well as being in a noisy environment.
The mandatory count is done in the same way of approximated seconds.
During the count, the opponent is instructed to move to a neutral corner.
It is the referee’s role to assess the fighter can or should continue based on observations of their physical and mental state. They may ask questions to assess the response and even plainly ask if they want to continue. The fight can be stopped if the downed boxer is in poor shape or does not respond to the referee’s satisfaction. It can be stopped after the action has resumed if they do not show enough recovery.