To mention the obvious, it’s the same network effect that keeps people on X and Reddit.
To stay obvious, what’s fascinating is that those networks are small, its members the most intelligent people available and they meet each other regularly in person at conferences.
Why do they accept the lock-in?
Not every community does it this way. For example, computational linguistics put most of their conference proceedings online for free: https://aclanthology.org/. Deep learning researchers just publish a lot of stuff to arxiv.
Academic publishers like Elsevier are predatory scammers.
The getting to keep your job bit is not quite right. Often, one also has to go find their own funding. Sort of based on the publications, but not necessarily.
Don’t forget that sometimes you also do work for that journal, telling them if a paper is good enough or not for them, and also basically don’t get payed.
Has there been an attempt at a charity-based distribution platform, á la Wikipedia?
Yes.
https://en.wikipedia.org/wiki/Academic_journal_publishing_reform?wprov=sfla1 (see Reform initiatives)
Bonus background:
https://pure.port.ac.uk/ws/portalfiles/portal/3696109/Military_Industrial_Complexities.pdf