Wow! What a word this turned out to be. Same word with three different meanings; each derived from a different source, according to the Dictionary of Etymology.
First it means sharply sour as the taste of lemons are tart.
Second it means a small pastry, filled with fruit or custard. You can combine meanings one and two and have a tart tart as in lemon tart.
Third meaning is a woman (perhaps these days a man or a transexual) of easy virtue. Get this, in Victorian days it was used as a term of endearment. As such it could be a derivative of the term “sweetheart.”
Combine the three meanings and you have the tart’s tart tart. Grammar checker is having kittens with that one. Red lines everywhere.