If you really need a formal definition, the ring $R[x]$ of polynomials over a (commutative) ring $R$ is defined as the set of all functions $f:\mathbb N \to R$ that have finite support, that is, $f(n)=0$ for all but a finite number of $n$. (Here $\mathbb N$ contains $0$.) That set is the same as the set of all sequences in $R$ that are eventually $0$.
The zero element in $R[x]$ is $(0,0,0,\dots)$.
The identity element in $R[x]$ is $(1,0,0,\dots)$.
$x$ is defined as $(0,1,0,\dots)$.
Addition is defined componentwise and multiplication is defined by $x^n=(0,0,\dots,1,0,\dots)$, where the $1$ is at the $n$-th position, and then expanded by linearity to general polynomials.
The result is that $f=(a_0,a_1,a_2,\dots,a_n,0,\dots)$ is the same as $a_0+a_1 x +a_2 x^2 + \cdots + a_n x^n$, as expected.
If you drop the requirement of finite support, you get the ring of formal power series over $R$.
If $R$ is not commutative, you need to declare that $x$ commutes with $R$.
But you really should focus on the operational definition: $R[x]$ is a ring that contains $R$ and $x$, and $x$ is subject to no other requirements except that is commutes with $R$, and what follows from the ring axioms. This implies the universal property of $R[x]$: If $R$ is a subring of $A$ and $a\in A$ commutes with $R$, then there is a unique ring homomorphism $R[x]\to A$ that fixes $R$ and sends $x$ to $a$. We also say that $R[x]$ is the free $R$-algebra over one element.