The simplest answer is a 14 line poem. It can be about any topic. But if it doesn’t have exactly 14 lines, it isn’t a sonnet. Traditionally, sonnets have followed other “rules” besides the 14 line rule.
Traditional sonnets must have some type of rhyme pattern. I write mine in the Shakespearian Sonnet form. That means the first line rhymes with the third, the second with the fourth, the fifth with the seventh, the sixth with the eighth, the ninth with the eleventh, the tenth with the twelfth, and the thirteenth with the fourteenth. Some sonneteers might use different rhyme patterns, but a rhyme scheme of some type is one of the defining characteristics of a traditional sonnet.
Another characteristic is some type of rhythmic structure, commonly called meter (or metre if you’re British). That means arranging the words so there is a rhythmic alternation of emphasis on the syllables within those words. In the Shakespearian form the meter is called iambic and puts the emphasis on every other syllable ( ta-tum, ta-tum ta-tum ta-tum ta-tum). Notice you just saw 5 ta-tums. When you have exactly 5 of those in each line, it’s called iambic pentameter, another Shakespearian sonnet characteristic.
Still another element of the sonnet is a shift in direction that takes place at line #9. The first 8 lines might introduce a topic or problem that gets clarified or resolved in the last 6 lines. The last 2 lines are what count the most. They might be a summation or a punchline, but the highlight of any good sonnet is what’s said in the final two lines.
Even Shakespeare didn’t always follow all the rules, and some very good sonnets ignore most of them, but they all have exactly 14 lines or it’s not a sonnet.