CAPM comes from Markowitz' portfolio theory. We study agents utility maximization behavior, and get results like two-fund separation. Every agent holds the tangency portfolio, combined with the risk-free asset.
So is it all as simple as saying "every agent holds tangency portfolio -> therefore it is the market portfolio in equilibrium?"