As it turns out, in the first part, you managed to find the correct $x$ along the way, but not very efficiently, and you overlooked a significant issue! Let's see how we can go about finding it deliberately, without issue.
If it doesn't immediately occur to us what value of $x$ might allow $xy=y$ to be true for all real $y,$ then we can start by trying to deduce a candidate for $x,$ then check to see if said candidate actually works for all real $y.$ Let's look at a couple of possible approaches to this, in order from least useful to most useful (in general).
Method 1: Suppose that $xy=y$ for all real $y.$ That means we can pick any particular real $y$ we want, and the equation must hold. Let's try $y=7,$ say. Then $xy=y$ becomes $7x=7,$ which we can easily solve to get $x=1.$ In fact, since this is the only solution $x$ to $xy=y$ when $y=7,$ then it is the only solution that might make $xy=y$ for all real $y.$ It is readily checked that if $x=1,$ then $xy=1y=y,$ and so we're done.
The drawback to this approach is that it relies to some extent on a good choice for $y.$ In this particular problem, that isn't a big deal, but in many problems it won't be so simple.
Method 2: Again, suppose that $xy=y$ holds for all real $y.$ We'd like to solve for $x.$ Now, it's tempting to divide both sides by $y$ to isolate $x$ on the left-hand side, but wait just a moment! There is a real number that we cannot divide by! In particular, we cannot divide by $y=0.$ Fortunately, if $y=0,$ it doesn't matter what $x$ we choose--the equation $xy=y$ will hold automatically, since both sides are $0.$ Whew! That issue has been averted. But what if $y\ne 0?$ Well, in that case, we can divide both sides by $y,$ yielding (as you saw in your work) $x=1.$ Again, this is easily confirmed to be correct.
The drawback to this approach is that we have to split by cases, and we have to notice that we have to split by cases (or risk division by $0$). Note that this approach uses the fact that $0y=0$ for all real $y.$ If you've not seen this result proved, I recommend you try to prove it, using the fact that $0+0=0,$ so that $(0+0)y=0y.$ See if you can take it from there.
Method 3: Again, suppose that $xy=y$ for all real $y.$ Put another way, $xy-y=0$ for all real $y,$ or by factoring, $(x-1)y=0$ for all real $y.$ Now, the only way two real numbers can have a product of $0$ is if at least one of the numbers is $0,$ so we know that $x-1=0$ or $y=0.$ (Note: This includes the possibility that both are $0.$) Since $y$ could be any real number, then we can't assume that $y=0,$ and so we must have $x-1=0,$ from which we once again find that $x=1.$
This approach is the best in terms of low risk, fewest cases, and general applicability. However, you may or may not have it to work with. I recommend that you attempt to prove it, if you haven't seen it proved. That is, prove the following statement:
If $a,b$ are real numbers such that $ab=0,$ then $a=0$ or $b=0.$
As for the second problem, we can use one of the above sorts of approaches to discover what $x$ must be (and I recommend that you practice the third method in particular to verify this), but you've already intuited that $x$ must be $0$! All you have to do now is observe that if $x=0,$ then for any real $y,$ we have $xy=0y=0=x,$ and so you're done!