For simplicity, I'll just talk about varieties that are sitting in projective space or affine space. In algebraic geometry, you study varieties over a base field k. For our purposes, "over" just means that the variety is cut out by polynomials (affine) or homogeneous polynomials (projective) whose coefficients are in k.
Suppose that k is the complex numbers, C. Then affine spaces and projective spaces come with the complex topology, in addition to the Zariski topology that you'd normally give one. Then one can naturally give the points of a variety over C a topology inherited from the subspace topology. A little extra work (with the inverse function theorem and other analytic arguments) shows you that, if the variety is nonsingular, you have a nonsingular complex manifold. This shouldn't be too surprising; morally. Morally, since "algebraic varieties" are cut out of affine and projective spaces by polynomials, whereas "manifolds" are cut out of other manifolds by smooth functions, and polynomials over C are smooth, and that's all that's going on.
In general, the converse is false: there are many complex manifolds that don't come from nonsingular algebraic varieties in this manner.
But in dimension 1, a miracle happens, and the converse is true: all compact dimension 1 complex manifolds are homeomorphic analytically isomorphic to the complex points of a nonsingular projective algebraic dimension-1 variety, endowed with the complex topology instead of the Zariski topology. "Riemann surfaces" are just another name for compact dimension 1 (dimension 2 over R) complex varietiesmanifolds, and "curves" are just another name for projective dimension 1 varieties over any field, hence the theorem you described.
As for why Riemann surfaces are algebraic, Narasimhan's book explicitly constructs the polynomial that cuts out a Riemann surface, if you are curious.