Aunt Polly finds out that Tom had been out swimming when Sid alerts her to the thread on Tom's collar. Instead of the original white thread she used to sew on Tom's collar, the thread is now black. This means that Tom took off his collar before he went for a swim. After the swim, he sewed the collar back on, except that he used black thread, instead of white (the color of the thread Aunt Polly originally used).
According to the text, Aunt Polly suspects that Tom skipped school to go swimming. However, she can't come up with clear proof to confirm her suspicions. After all, the shirt collar appears to be securely sewn onto Tom's jacket. The only evidence that Aunt Polly can point to is that Tom's hair is wet.
As for Tom, he tells Aunt Polly that he merely wet his hair with water. Aunt Polly gives up her line of questioning. However, Sid (Tom's half-brother) pipes up with “Well, now, if I didn't think you sewed his collar with white thread, but it's black.”
At this, Tom quickly makes a getaway. Sid's revelation upsets Tom, and he consoles himself with the fact that he'll make Sid pay for outing him.