In fact, since the authors both do the work of creating the content and peer-reviewing submissions, they must also pay the journal in exchange for doing this work.
Think of it like the patient paying the hospital, the doctor paying the hospital, and in exchange the doctor can do their work at a prestigious hospital, which is all very lucrative (for the hospital)