The login gating on Twitter was relatively recent (within a year or two, IIRC) before Musk took over, and also relatively mild. Non-logged-in users could still read most tweets, conversations, lists, etc. It was annoying and user-hostile though.
When Musk's people took over they very briefly removed any login gate, then very soon after they completely blocked all meaningful non-logged-in access to the site. Which is frankly fine with me: it's a good reason to never visit a place that has become a cesspool of scams, porn, and white supremacist propaganda.
It was a pretty shithouse experience as a non-logged-in user before Musk, but it's a worse experience now.
Timelines were all over the place before Musk got his hands on it. And if timelines are all over the place, what's the point? (that was always my view as someone who's not logged in - and as a 'town square', I would have thought that getting its message(s) across to as many people as possible would be a goal. But no, it's just another in-club like all the others. Fuck 'em, walk on by).
X has gone harder on login gating than the old Twitter they adopted for sure. Reddit also started going in this direction. Instagram has had it for a long time.
I suspect selling APIs for AI is playing a big role in that.
Reddit locked down their API around the time X started forcing logins (july 2023).