Could someone please see whether my solution is okay?
If $f:X\to Y$ with $A_{1},A_{2}\subset X$, show that $f(A_{1}\cup A_{2})=f(A_{1})\cup f(A_{2})$.
Let $y\in f(A_{1}\cup A_{2})$. Then there exists an $x\in A_{1}\cup A_{2}$ such that $f(x) = y$. Then $x\in A_{1}$ or $x\in A_{2}$. If $x\in A_{1}$, then $y\in f(A_{1})$. If $x\in A_{2}$, then $y\in f(A_{2})$. In either case, $y\in f(A_{1})\cup f(A_{2})$. Then $f(A_{1}\cup A_{2})\subset f(A_{1})\cup f(A_{2})$.
Let $y\in f(A_{1})\cup f(A_{2})$. Then $y\in f(A_{1})$ or $y\in f(A_{2})$. If $y\in f(A_{1})$, then there exists an $x\in A_{1}$ such that $f(x) = y$. Then $x\in A_{1}\cup A_{2}$. Then $y\in f(A_{1}\cup A_{2})$. If $y\in f(A_{2})$, then there exists an $x\in A_{2}$ such that $f(x) = y$. Then $x\in A_{1}\cup A_{2}$. Then $y\in f(A_{1}\cup A_{2})$. In either case, $y\in f(A_{1}\cup A_{2})$. Then $f(A_{1})\cup f(A_{2})\subset f(A_{1}\cup A_{2})$.
Your proof is good and detailed.
Part of it could be modified by noticing that $$A_1 \subseteq A_1 \cup A_2 \implies f(A_1)\subseteq f(A_1 \cup A_2).$$
Similarly $$A_2 \subseteq A_1 \cup A_2 \implies f(A_2)\subseteq f(A_1 \cup A_2).$$