Best to be sure… reinstalling Mac OS is the easiest way to give complete piece of mind when you don’t know what’s been done to the system before it’s in your hands. Except from receiving the laptop new.Fuzz, reinstalling the OS is nuking the site from orbit, and reinstalling OSes, especially APFS OSes on silicon hardware, ought not be suggested if there's even a remote possibility that the machine's linked ID is frazzled in the least. I.e., you ⌘R your way through the reinstall process, and it gets to the step where Apple requests an ID to finish installation (thoughtful of them to wait until the very end), but it doesn't like the one you enter. Congratulations: you now own a brick. --Given that the OP had Apple ID issues, reinstalling is the absolute last thing I would do with a still-functioning machine.
So far, we don't even know what the problem is, specifically, or even if they're singular. From the OP description, it sounds like a typical corporate data-breach of the type we see every odd week now, with users having to update their passwords again (ad nauseum), and that happened to sort of coincide the day before a bunch of 3rd-party peripheral hardware connection issues possibly resultant from Sonoma not being perfect in every way <tremendous eyeroll>, which the OP appears to have resolved (fingers crossed). The OP then wrote: "I found out that my computer was used to access the Only Fans site....", emphasis on site, as in perhaps somebody made use of an open Safari window while the owner was temporarily absent and the screensaver hadn't yet kicked in. (Would it be indelicate to inquire if there are children in the house? Methinks not.) Or said browser was being run without adblocking (because Safari doesn't come with it by default), and you never know where the innocuous rectangle you absentmindly clicked will send you.
Basically, if Safari (if they're still using it against my advice) isn't exhibiting any redirect behavior, and their peripherals are behaving, and Malwarebytes chucjed a thing or two, I'd consider the problems resolved. (At least until the next installment of Sonoma Update Bingo spins the ball-container.)
It’s relatively quick and easy to be back up and running again.