True, with emphasis on fully.
> In many cases, the systems to collect fares end up costing hundreds of millions of dollars.
That figure seems extremely high for "many cases," but the exact figure isn't really material.
> These costs are never made back. It makes sense to make it free.
No, that's just not true.
My local metro spent $17 million on fare collection to net $167 million in revenue (2019). It would have to cut $150 million in other service to go to free fares.
https://en.wikipedia.org/wiki/Farebox_recovery_ratio
In many parts of the developed world the ratio is 30% plus which can be an enormous amount of money. In Boston fare revenue is 500M .
Making things free would cause big issues for many of them as you say.