Collaborative Learning with Shared Linear Representations: Statistical Rates and Optimal Algorithms