Preflop, flop and turn are obviously fine. On the river you should have jammed all in for value. Sure he can now have a better boat than yours, but its way more likely, he just has trips. AK should have 3-bet pre or check-raised the flop, A8 is almost impossible, because you block it, and if he can have A2, then he can also have A3-A7 as well as A9-AQ.
A bad player is certainly able to donk lead the river with just trips, and its very unlikely, he is going to fold to a jam. So while just calling saved you money this time, you are missing out in the long run, and this is never ever a fold. If he is bad enough to play AK or A2 like this and cooler you with a better boat, good for him.
__________________
|