I agree that someone with trading authority over another person's account who does so without compensation (e.g. an adult child with a power of attorney authorizing them to trade in their incapacitated parent's account) is not an Investment Advisor subject to regulation under the Investment Advisors Act of 1940 (the pertinent definition is here).
If person X buys the XYZ stock (a name I made up) in person's Y
account, can he legally buy it for his own account the same day? I
believe not. He needs to wait some time. How long does he need to
wait? 1 day? 3 days?
It is not clear from the question what kind of transaction you are talking about. Are you asking if X can buy the particular shares of stock that are in Y's account, or are you asking if X can buy XYZ shares on the open market for X's account after having also done so for Y?
Also, if you believe not, why would you have that belief? Do you believe that this would constitute a form of indirect compensation?
Someone who has the authority to trade in another person's account for that other person's benefit is necessarily some sort of fiduciary and owes fiduciary duties of loyalty to Y.
It isn't clear to me why making a parallel purchase of the same stock purchased for Y on X's own account would violate the fiduciary duty that X owed to Y. But perhaps I am not understanding some aspect of the transaction described in the question that is pertinent.