They had success before TikTok. Sarah J Maas, for example, was a huge hit with teens back when I started working as a YA librarian 10 years ago. TikTok didn't exist then. But social media has definitely been a marketing tool of savvy authors and publishers since it began.
These novels are written to appeal to teen girls and feature strong female characters often depicted as breaking into a "man's" world and standing against traditional roles assigned by their culture. And, of course, there's always the supportive young man, typically a person in line for power (as a prince), who winds up being the romantic interest. (And yes, this does sound like a typical fairy tale— indeed recast fairy tales are a big element of this genre, sometimes even directly presented (as Cinder and its sister novels, which use classic fairy tales transformed into science fiction.)
I've read one of Maas's works. Honestly, I thought it read like decent quality D&D fanfic. Well-paced and full of action, but generally derivative of stuff we've all read before. The premise was a young female assassin of mysterious background is competing to be the King's Assassin, but she secretly wants to avenge her culture against the King's conquest. In the midst of this, she stumbles on a plot that means she will have to protect the king to prevent a far worse outcome, while she becomes attracted to the king's son, but also to a young, straight-laced captain of the king's bodyguard (think AD&D paladin without the magic powers). Ooo, romantic tension. Hardly an original premise. But girls love these books, so there you go.
TikTok may help sell them now, but they were hot properties long before TikTok.