Ok so I seem to be missing something here.
I know that the number of independent coefficients of the Riemann tensor is $\frac{1}{12} n^2 (n^2-1)$, which means in 2d it's 1 (i.e. Riemann tensor given by Ricci Scalar) and in 3d it's 6 (i.e. Riemann Tensor given by Ricci tensor).
But why does that constrain the Riemann tensor to only be a function of the metric? Why not a tensorial combination of derivatives of the metric?
What I mean is why is the Riemann tensor in 2D of the form \begin{align} R_{abcd} = \frac{R}{2}(g_{ac}g_{bd} - g_{a d}g_{b c}) \end{align}
and in 3D, \begin{align} R_{abcd} = f(R_{ac})g_{bd} - f(R_{ad})g_{bc} + f(R_{bd})g_{a c} - f(R_{bc})g_{ad} \end{align} where $f(R_{ab}) = R_{ab} - \frac{1}{4}R g_{ab}$?
Wikipedia says something about the Bianchi identities but I can't work it out. A hint I got (for the 2d case at least) was to consider the RHS (the terms in parenthesis) and show that it satisfies all the required properties of the Riemann tensor (sraightforward) and proceed from there - but, I have not been able to come up with any argument as to why there must be a unique tensor satisfying those properties.
Of course I could brute force it by computing $R_{abcd}$ from the Christoffel symbols etc., but surely there must be a more elegant method to prove the statements above.
Help, anyone? I haven't been able to find any proofs online - maybe my Googling skills suck.