Just asking a special case of attaching, it seems pretty vague to me.
Let $Y$ be a space and $X$ be its subspace. Then the space obtained by $Y$ attaching its subspace $X$ via $\iota$ (the embedding) is defined to be the quotient of the coproduct $X\coprod Y/\sim $ in which $\sim$ is the equivalence relation generated by the relation $x \sim \iota(x)$. Can u tell me what this space is explicitly?
Intuitively, I think the answer is just $Y$, I imagine $X\coprod Y$ is just the disjoint union of two sets, and the equivalence relation implies that every two identical points $(x,\iota(x)) \in X\times Y$ is the same. So to sum up, the result is Y.
What are you actually asking about is called the adjunction space.
Now specializing to your question above we have the inclusion map $i : X \to Y$ defined by $i(x) = x$ and note that since $X$ is a closed subspace of itself and $i$ is continuous we can form the adjunction space $$Y \cup_i X = \left(Y \sqcup X\right) / \sim$$ where $\sim$ is the relation generated by $(x, 2) \sim (i(x), 1)$ for $x \in X$. But then by definition of $i$ it follows that $\sim$ is the relation generated by $(x, 2) \sim (x, 1)$ for $x \in X$.
Before we can quotient out the disjoint union, we first need to see what this relation actually is. The equivalence relation generated by $(x, 2) \sim (x, 1)$ for $x \in X$ is the smallest equivalence relation on $Y \sqcup X$ that has this property. So basically under this equivalence relation for a fixed $x \in X \subseteq Y$ it follows that $(x, 2)$ and $(x, 1)$ belong to the same equivalence class in $\left(Y \sqcup X\right) / \sim$ and each $(y, 1)$ has it's own equivalence class $\{(y, 1)\}$ for all $y \in Y \setminus X$. So set-theoretically we have that
\begin{align*}\left(Y \sqcup X\right) / \sim \ &= \left\{[ (x, 1)] \ | \ x \in X \subseteq Y \right\} \cup \left\{[(y, 1)] \ | \ y \in Y \setminus X\right\} \\ &= \left\{\{(x, 2), (x, 1)\} \ | \ x \in X \subseteq Y \right\} \cup \left\{\{(y, 1)\} \ | \ y \in Y \setminus X\right\} \end{align*}
We now appeal to the following theorem to finish off this proof.
Let $q : Y \sqcup X \to Y \cup_i X$ be the natural quotient map defined by $q(a, i) = [(a, i)]$.
Appealing to the uniqueness of quotient spaces this motivates us to define a quotient map $f$ such that $f(x,2) = f(x,1)$ for all $x \in X$ and $f(y, 1) = (y, 1)$ for all $y \in Y \setminus X$. The projection map $f : Y \sqcup X \to Y$ defined by $f(a, i) = a$ is precisely the map that achieves this outcome. Note that $f$ is quotient map, the fact that $f$ is a quotient map follows from the definition of the disjoint union topology.
We claim that $f$ and $q$ make the same identifications. To prove this we need to show that $q(a, i) = q(b, j) \iff f(a, i) = f(b, j)$. I will prove the forward direction, the reverse direction follows similarly.
Suppose that $q(a, i) = q(b, j)$.
If $(a, i) = (x, 2)$ for some $x \in X$ then $(b, j) = (x, 2)$ or $(b, j) = (x, 1)$ (by definition of the relation generated by $\sim$ and $q$). In either case $f(a, i) = f(x, 2) = x$ and $f(b, j) = x$, hence $f(a, i) = f(b, j)$ as desired.
If $(a, i) = (x, 1)$ for any $x \in X$, then $(b, j) = (x, 1)$ or $(b, j) = (x, 2)$ (again by definition of the relation generated by $\sim$ and $q$). In either case we have $f(a, i) = f(x, 1) = x = f(b, j)$ as desired.
If $(a, i) = (y, 1)$ for any $y \in Y$, then $(b, j) = (y, 1)$ (again by definition of the relation generated by $\sim$ and $q$). Hence $f(a, j) = f(y, 1) = y = f(b, j)$ as desired.
Since these cases exhaust all possible choices for $(a, i)$ and $(b, j)$ for which $q(a, i) = q(b, j)$ it follows that $q(a, i) = q(b, j) \implies f(a, i) = f(b, j)$ proving the forward direction.
After proving the reverse direction it follows that $q$ and $f$ make the same identifications and since they are both quotient maps, by the theorem above it follows that the following diagram commutes
and that there exists a unique homeomophism $\varphi$ from $Y \cup_i X$ to $Y$ hence $$Y \cup_i X \cong Y.$$