Disclaimer: I do not assume rings to be unital (otherwise the question wouldn't make sense).
Give examples of a ring $R$ with subring $S$ such that
(1) $R$ has an identity but $S$ has not.
(2) $S$ has an identity but $R$ has not.
Attempt:
(1) Take $R = \mathbb{Z}$ and $S = 2 \mathbb{Z} = (2)$
Suppose that $S$ has an identity $e$, then we must have (in $S$)
$$2e = 2$$
This is also true in $R$, and thus we can conclude $e = 1$. But $1 \notin S$. Contradiction. Thus $S$ has no idenity.
(2) Take $R$ the compactly supported functions $\mathbb{R} \to \mathbb{R}$. This is easily seen to be a subring of the set of all functions $\mathbb{R} \to \mathbb{R}$ (and in fact thus also gives an example for (1), as this ring has identity $f = 1$). Suppose $R$ has an identity $g$. Take a function $l$ that is non-zero everywhere. Then we must have
$$lg = l \implies l(g-1) = 0 \implies \forall x \in \mathbb{R}: g(x) = 1 \implies g = 1$$
But $g \notin R$. Thus $R$ has no identity.
Define a function $k$ as the indicatorfunction $k= I_{[0,1]}$ which is $1$ on $[0,1]$ and $0$ elsewhere. This function is compactly supported and an idempotent. Hence, the ideal $(k) = kR$ is a subring with identity $k$ (since $(kr)k = k^2r = kr$).
Observation: If $R$ has an identity that also lives in $S$, this is also the identity for $S$. Thus the only way $S$ can be non-unital when $R$ is unital is that the idenity of $R$ does not live in $S$.
Is this correct?
Yes, both examples and the observation are correct.
Note for (2), that any idempotent element $e$ (even in a nonnecessarily commutative ring) gives rise to a subring with identity, namely $eRe$.