It's originally from the US but is now used worldwide, and the earliest examples describe times in running, bicycle and horse races that are dead on to the whole second, rather than a number of seconds and fractions (typically fifths) of seconds.
This may because the second hand was exactly flat against the second mark on the watch dial, and not in between. For a modern analogy, you can compare it to an exact measure of, say, a litre of flour where the top is levelled off and there's no discrepancy.
The OED's first citation is a 1909 dictionary, but I found a 26-year antedating.
The National Republican (Washington City (D.C.), May 15, 1883) gives horse racing results:
Joe Murray, who is looked upon as a very possible winner of the handicap, went a half mile in fifty seconds flat by three watches, but pulled up seemingly tired.
The San Francisco Call (May 01, 1898) gives some times with fractions of seconds, and one in seconds flat:
He took the sticks beautifully and in the fast time of 15 4-5 seconds. ... Morgan ran the 220 hurdles in 26 seconds flat, equaling Torrey's record made on an Eastern track.