Finding the economical way to do it costs a lot of money. The economies of scale that solar needed to reach before it became the low cost option were built on enormous subsidies from Germany, China and others.
Then let's also add the state-owned coal/fossil companies kept artificially afloat, producers tax expenditures, publicly funded rail transport or handling infrastructure or water systems, subsidized coal electricity prices... then indeed we can discuss apples to apples.
can't help but wonder if the aggregate of the solar PV subsidies made in the last 25 years are higher or lower than the aggregate of energy price subsidies made when the Ukraine and/or Iran wars made fossil fuel prices spike...