It looks like you have just started ring theory so I will show you how to do these kinds of things.
$\underline{\implies}$ Suppose you have that $(a) : = \{ra : r\in R\}$ is equal to the whole ring $R$. This means that given any element in $R$, it is in $(a)$ and vice versa. We take advantage of the first inclusion, namely that given any element in $R$, it is an element in $(a)$. In other words we would like to take advantage of the fact that $(a) \subseteq R$. Now in particular we can take the identity element $1_R \in R$, since $1_R \in (a)$ by our subset inclusion. Therefore this means by definition of $(a)$ that we can write $1_R$ as the product of $a$ and some element in $R$. In other words, there exists some $r \in R$ such that
$ra = 1_R.$
Note that $r$ cannot be zero for then $0\cdot a = 1_R$ which is impossible unless $R$ is the zero ring, which we exclude here otherwise there is nothing to prove. Now the statement $ra= 1_R$ means that $r$ is a left-inverse for $a$. However since we are in a commutative ring, this means that $ra = 1_R$ too so that $r$ is a two-sided inverse for $a$, that is that $a$ is invertible.
$\underline{\Leftarrow}$ Now suppose that $a$ is a unit in $R$. This means that $a^{-1}$ exists and $a^{-1}$ is such that
$a^{-1}a = aa^{-1} = 1_R.$
Now by definition $(a)$ is the set of all multiples of $a$. Since $a^{-1} \in R$, it must be the case that $a^{-1}a \in (a)$ by definition of $(a)$. In other words, $1_R \in (a)$. Now we already know that $(a) \subseteq R$. We also know in addition that $(a)$ is an ideal and hence must be closed under multiplication "from the outside". This means to say that given any $\alpha \in (a)$ and $r \in R$, $\alpha r$ must be in $(a)$. Therefore since $1_R \in (a)$, this means that for all $r \in R$,
$1_R \cdot r = r$
must be in $(a)$. But then this is exactly saying that $R \subseteq (a)$. Since we already had the inclusion $(a) \subseteq R$, this forces
$(a) = R.$
Is this clear to you now? I can always discuss with you in the comments below if you wish.