So I am studying about classical algebraic geometry (the one working with affine varieties instead of schemes) and I suppose I'm lost in a number of points. Note that I'm trying to study affine varieties/algebraic sets so please make sure that you're not talking about the setting with schemes. I'll begin with clarifying my definitions of these objects and then proceed to ask about my confusions.
If $k$ is an algebraically closed field and $X=V(f_1,\dotsb,f_m)\subseteq\mathbb{A}_k^n$ is an affine algebraic set, it can be shown that $A(X)=k[X_1,\dotsb,X_n]/I(X)$ (the affine coordinate ring), is a finitely generated reduced $k$-algebra. It is furthermore known to be a domain if and only if the affine algebraic set is irreducible, hence and affine algebraic variety. $\mathrm{Spec}$ seems to be a functor to associate to any finitely generated $k$-algebra an affine algebraic set. But there are two seemingly different definitions for this functor:
Supposing that $R$ is a finitely generated $k$-algebra, it is isomorphic to some $k[X_1,\dotsb,X_n]/I$ where $I$ is a finitely generated ideal as it is the kernel of the corresponding surjection $R\to k[X_1,\dotsb,X_n]$. Therefore, suppose that $I=\langle g_1,\dotsb,g_r\rangle$. We then define $\mathrm{Spec}(R):=V(\langle g_1,\dotsb,g_r\rangle)$ which is an algebraic set and inherits the Zariski topology of $\mathbb{A}_k^n$.
Supposing $R$ is a commutative ring, one can define $\mathrm{Spec}(R)$ as its set of prime ideals and then equip it with the Zariski topology on $\mathrm{Spec}(R)$.
So here are the first of my questions:
First of all, how can the second definition be realized as an algebraic set? If not true in general, under what conditions is it an affine algebraic set? How/under what conditions do the topologies of these sets agree?
If I recall correctly, $A(\mathrm{Spec}(R))\cong R$. What are the exact conditions for this isomorphism? Since this implies that $R$ is a reduced algebra (as the affine coordinate ring of some affine algebraic set) which is not the case in general since as I understand, defining $\mathrm{Spec}(R)$ does not require $R$ to be reduced.
The second definition does not even require $R$ to be finitely generated. To what extent, then the relation $A(\mathrm{Spec}(R))\cong R$ hold?
So as the affine coordinate ring is basically a contravariant functor from the category of affine algebraic sets to the category of finitely generated reduced $k$-algebras (or restricting to irreducible sets, from the category of affine algebraic varieties to the category of finitely generated $k$-algebras whose underlying ring is an integral domain), $\mathrm{Spec}$ is supposed to be a contravariant functor in the opposite direction. One could also equip an affine algebraic variety with a compatible group structure, deriving what is called an algebraic group. Then it is intuitively clear to me that this would in turn induce dual operations on the coordinate rings, making them a sort of Hopf algebra. But how can one show (probably by means of some sort of Yoneda lemma) that the category of affine algebraic groups is the same as the category of finitely generated Hopf algebras (that are to my understanding, $k$-algebras equipped with a compatible co-group structure), thus making this equivalence more rigorous?
Finally I have the same question on algebraic actions. How can one derive the co-action of $k$-algebras as a sort of equivalent object to algebraic actions of an algebraic group? I tried to do so by the Hom-tensor adjunction but could not derive what I initially sought for. Also, an algebraic action on a variety $X$ yields an algebraic action on $\mathcal{O}(X)$ by means of some sort of pullback. Does this mean that this action simultaneously yields an action and a co-action on $A(X)$? If so, how do these two relate to eachother?
Any help, hint, explanation or resources would be extremely helpful and appreciated. Thanks for your time!