There's not that much difference between the two cases. 1 out if he has the lower set, versus 2 outs if he has AA. You didn't want him to fold the flop with just two outs, you wanted him to give you his stack the 95% of the time he doesn't hit an A on the turn. Any donk who will play AA like that on the flop probably thinks he has disguised his hand really cleverly and will be going to the mat on the turn anyway.
So you played it perfectly, except for not realizing he was the preflop raiser. If you realize that, then you might be able to fold the turn and save some money. But your flop play was fine against this guy, IMO.